R
Rolf Welskes
Hello,
because there are no news group for window presentation foundation and one
has told me I can use this, here my problem:
I make the following binding in code:
SolidColorBrush mySolidColorBrush = new
SolidColorBrush(Colors.Green);
Binding bdx01 = new Binding();
bdx01.Source = mySolidColorBrush;
BindingOperations.SetBinding(myTextBlock01,
TextBlock.BackgroundProperty, bdx01);
Binding bdx02 = new Binding();
bdx02.ElementName = "myPanel"; //myPanel
is the name of the Control I where I am here.
bdx02.Path = new PropertyPath("MyColor");
BindingOperations.SetBinding(mySolidColorBrush,
SolidColorBrush.ColorProperty, bdx02);
Remark: MyColor property is declared in this code before as
DependencyProperty.
So if I would change MyColor so mySolidColorBrush should change the color
and so myTextBlock-Background should change.
It s here to see that binding can be in a chain.
This sampel does not work.
BUT if I add the following line:
myTextBox.Background = mySolidColorBrush; //myTextBox is any
textbox
then all works fine.
We have: myTextBlock.Background is bind to mySolidColorBrush
and mySolidColorBrush is bind to MyColor
Why does this only work, if I add the line where an element get the brush
directly.
Thank you for any help.
Rolf Welskes
because there are no news group for window presentation foundation and one
has told me I can use this, here my problem:
I make the following binding in code:
SolidColorBrush mySolidColorBrush = new
SolidColorBrush(Colors.Green);
Binding bdx01 = new Binding();
bdx01.Source = mySolidColorBrush;
BindingOperations.SetBinding(myTextBlock01,
TextBlock.BackgroundProperty, bdx01);
Binding bdx02 = new Binding();
bdx02.ElementName = "myPanel"; //myPanel
is the name of the Control I where I am here.
bdx02.Path = new PropertyPath("MyColor");
BindingOperations.SetBinding(mySolidColorBrush,
SolidColorBrush.ColorProperty, bdx02);
Remark: MyColor property is declared in this code before as
DependencyProperty.
So if I would change MyColor so mySolidColorBrush should change the color
and so myTextBlock-Background should change.
It s here to see that binding can be in a chain.
This sampel does not work.
BUT if I add the following line:
myTextBox.Background = mySolidColorBrush; //myTextBox is any
textbox
then all works fine.
We have: myTextBlock.Background is bind to mySolidColorBrush
and mySolidColorBrush is bind to MyColor
Why does this only work, if I add the line where an element get the brush
directly.
Thank you for any help.
Rolf Welskes