|
|
Fill property of a Rectangle takes in a string. Try giving the name of color1 instead of the Color itself. It will work.
|
|
|
|
|
Hi there.
I want to convert Brushes.* to the hexadecimal numbers to using in HTML's files.
For example I'd like to convert Brushes.Black to the #000000 or Brushes.White to the #FFFFFF.
Can you help me ?
Freshman
|
|
|
|
|
Well - you can always get this using the Colors.A, Colors.R, Colors.G and Colors.B from the brush colour.
|
|
|
|
|
Thank you.
Can you write a sample code (Please)
I'm new
Freshman
|
|
|
|
|
Thinking about it, the simplest way is to do this:
SolidColorBrush brush = Brushes.Aqua ;
string color = string.Format("#{0}",brush.ToString().Substring(3)); The brush includes an alpha component at the start, so you need to remove it from the text. This means you need to do a substring on the ToString() which returns the full ARGB version of the colour.
|
|
|
|
|
Nice
You're expert in WPF.
Thank you very much Pete
Freshman
|
|
|
|
|
I have the Implementaion for Displaying treeListView but, don't know how to do DragDrop in it??
|
|
|
|
|
Josh has an excellent article here[^] that can be easily adapted to treeview drag/drop.
|
|
|
|
|
hi,
how we can set F1 key for image button to open chm file in wpf
|
|
|
|
|
I have got it.
Add Window.CommandBindings in xaml file.
Add tag CommandBinding Command='ApplicationCommands.Help' Executed='OnClickContents' as the child of </Window.CommandBindings>
We can write code under event handler for event Executed.
|
|
|
|
|
Hello friends.
I want to get richTextbox's text in wpf.
How can I do it ?
Something like this : richTextBoxText.Text
Freshman
modified on Wednesday, July 2, 2008 1:26 AM
|
|
|
|
|
I have created flowdocument name="flowData" as the child of rich texrt box and paragraph as the child of Flow document in the xaml file.
In the cs file I have created TextRange object and passed the flowdocument.ContentStart and flowdocument.ContentEnd
eg: TextRange documentRange = new TextRange( flowData.ContentStart, flowData.ContentEnd );
then documentRange.Text returns the data entered in rich text box.
|
|
|
|
|
Did you mean :
RichTextBox rtb = richTextBoxText as RichTextBox;
TextRange tr = new TextRange(rtb.Document.ContentStart,rtb.Document.ContentEnd);
Freshman
|
|
|
|
|
Hi there.
I want to convert "Black" string to Brush in WPF.
How can we do it?
Freshman
|
|
|
|
|
One way is to use the BrushConverter:
BrushConverter conv = new BrushConverter();
SolidColorBrush brush = conv.ConvertFromString("Black") as SolidColorBrush;
|
|
|
|
|
Wow, nice reply.
Thank you.
Freshman
|
|
|
|
|
|
Don't cross post.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
---modified. Original problem with this is solved, but I got a new problem with the same xaml ---
Ok I just started in WPF so it might be very obvious.
I made a UserControl which contains also a ToggleButton, when that togglebutton is pressed I want to alter the background of the border control.
<UserControl x:Class="StoreDBViewer.MyTableControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<Grid>
<Border x:Name="MyCtrlBorder" BorderThickness="1" BorderBrush="Gray" Background="Green">
<!-- Here a bunch of controls and stuff is added -->
<ToggleButton x:Name="btnToggle" Margin="5,5" Click="OnToggleColView">
Button text
</ToggleButton>
</Border>
</Grid>
<UserControl.Triggers>
<Trigger SourceName="btnToggle" Property="ToggleButton.IsChecked" Value="True">
<Setter TargetName="MyCtrlBorder" Property="Border.Background" Value="Blue" />
</Trigger>
</UserControl.Triggers>
</UserControl>
This compiles correctly, but as soon as I run the app an exception is thrown( the exception is not thrown if I comment out the Trigger part).
Does anyone know what might be wrong here?
Regards,
Davy
modified on Monday, June 30, 2008 8:55 AM
|
|
|
|
|
What is the error message of the exception (or the message of the InnerException, or the InnerException of the InnerException, or however many levels it takes to find something useful)? In cases like this, the error messages usually have a good pointer for where to start looking.
|
|
|
|
|
Thanks for the reply.
The message of the exception itself was pretty useless, but following the innerexceptions 3 levels up I came to this message:
Triggers collection members must be of type EventTrigger.
So doing some research on that I found that this kind of trigger only works in ControlTemplate,DataTemplates and Style... So I guess I have to reorder some stuff in the xaml file to fit the triggers somewhere in a style or so.
Regards,
Davy
|
|
|
|
|
OK, this is a small WPF application that I am working on.
While testing, no problem appeared. Even when using the exe that would be released to everyone.
Now, in one of the text boxes I had put UndoLimit=-1, to avoid the problems with the undo limit. This worked perfectly on my machine. But a user reported this:
Exception: System.Windows.Markup.XamlParseException
28/06/2008 14:01:28
Message: Cannot find DependencyProperty or PropertyInfo for property named 'UndoLimit'.
Property names are case sensitive. Error at object 'txtDNA' in markup file 'Origones;component/mainwindow.xaml'.
Source: PresentationFramework
STACK TRACE
Void ThrowException(System.String, System.Exception, Int32, Int32, System.Uri,
System.Windows.Markup.XamlObjectIds, System.Windows.Markup.XamlObjectIds, System.Type)
at System.Windows.Markup.XamlParseException.ThrowExce ption(String message,
Exception innerException, Int32 lineNumber, Int32 linePosition, Uri baseUri,
XamlObjectIds currentXamlObjectIds, XamlObjectIds contextXamlObjectIds, Type objectType)
[Note: Some newlines added]
[Snipped]
Strangely enough, simply removing the UndoLimit fixed it.
Another problem with the same application: One of the users reported that the "portrait" had a purple tint. That problem is in this screenshot.[^]
Now, viewing the same files on my computer, and apparently everybody else's resulted in the correct coloring.
Has anybody had any experience with these strange small inexplicable problems?
modified on Sunday, June 29, 2008 9:44 AM
|
|
|
|
|
Looking at the UndoLimit documentation it appears this was added in 3.0sp1 so it could be a versioning issue for that user. The WPF performance tool has an option to tint software rendering in purple, perhaps that debug option got enabled or some graphics driver is causing problems? Does the portrait have any BitmapEffects applied to it which would cause it to be rendered in software?
The image you posted didn't work for me but perhaps you could test with the option enabled and see if they match, the part about deleting the registry key might help that user.
http://msdn.microsoft.com/en-us/library/aa969767.aspx#perforator
|
|
|
|
|
Please help. I tracked down a bug down to the fact that a toggle button in my app ignores it’s binding. I’ve simplified to the enclosed example WPF app. What I want is the BoundToChecked toggle button to only reflect the real value of ValueSource.Checked. What occurs is when the BoundToChecked toggle button is clicked it changes visual state even if ValueSource.AllowChange is false!
Any suggestions or advice would be most appreciated.
Thanks,
Ron
<br />
<br />
using System;<br />
<br />
using System.ComponentModel;<br />
<br />
namespace ToggleButtonBound<br />
<br />
{<br />
<br />
class ValueSource : INotifyPropertyChanged<br />
<br />
{<br />
<br />
private bool _allowChange;<br />
<br />
public bool AllowChange<br />
<br />
{<br />
<br />
get { return _allowChange; }<br />
<br />
set<br />
<br />
{ <br />
<br />
_allowChange = value;<br />
<br />
OnPropertyChanged("AllowChange");<br />
<br />
}<br />
<br />
}<br />
<br />
private bool _checked;<br />
<br />
public bool Checked <br />
<br />
{ <br />
<br />
get {return _checked;}<br />
<br />
set<br />
<br />
{<br />
<br />
if (AllowChange)<br />
<br />
{<br />
<br />
_checked = value;<br />
<br />
OnPropertyChanged("Checked");<br />
<br />
}<br />
<br />
}<br />
<br />
}<br />
<br />
#region INotifyPropertyChanged Implementation<br />
<br />
public event PropertyChangedEventHandler PropertyChanged;<br />
<br />
protected virtual void OnPropertyChanged(string property)<br />
<br />
{<br />
<br />
if (PropertyChanged != null)<br />
<br />
{<br />
<br />
PropertyChanged(this, new PropertyChangedEventArgs(property));<br />
<br />
}<br />
<br />
}<br />
<br />
#endregion<br />
<br />
}<br />
<br />
}<br />
<br />
<br />
<br />
<br />
<Window x:Class="ToggleButtonBound.Window1"<br />
<br />
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"<br />
<br />
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"<br />
<br />
xmlns:me="clr-namespace:ToggleButtonBound"<br />
<br />
Title="ToggleButtonBound" Height="300" Width="300"><br />
<br />
<Window.Resources><br />
<br />
<me:ValueSource x:Key="ValueSource" /><br />
<br />
</Window.Resources><br />
<br />
<StackPanel><br />
<br />
<ToggleButton Content="Unbound"/><br />
<br />
<ToggleButton Content="BoundToChecked" IsChecked="{Binding Source={StaticResource ValueSource}, Path=Checked, Mode=Default}"/><br />
<br />
<CheckBox Content="AllowChange" IsChecked="{Binding Source={StaticResource ValueSource}, Path=AllowChange, Mode=Default}"/><br />
<br />
</StackPanel><br />
<br />
</Window><br />
Sincerely,
-Ron
|
|
|
|