![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
| |
| | #1 (permalink) |
| | Databinding not working on Borders ? I am trying to databind a color to a Border control. The goal is to have the border as 100% opaque and the background filled with the same color, but with only 10% opacity. Here's the relevant XAML: <Border BorderThickness="2" Padding="2"> <Border.BorderBrush> <SolidColorBrush Color="{Binding Owner.Color}" /> </Border.BorderBrush> <Border.Background> <SolidColorBrush Color="{Binding Owner.Color}" Opacity="0.1" /> </Border.Background> .... Now the result is really confusing. The Background is filled correctly, but the border is transparent!!! I see 2 things which could go wrong: 1. The databinding is not working (wrong Path, null object, whatever). But this is obviously not the case, since the Background - which uses the very same binding - is working perfectly! 2. The BorderBrush doesn't work like I think it does. But just replacing the binding expression with a constant "Red" works flawlessly. So it's probably alright too. Can you guess what can go wrong with such a simple example ? Is this a bug in WPF ? |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Databinding not working on Borders ? I can't see why that doesn't work. My guess is 1. Are you seeing any binding errors in the output? Is the background that is being drawn possibly from the control inside the border? Something like this would allow you determine if the background is actually being set correctly. (following is tested) <Border BorderThickness="2" Padding="2" Name="Border"> <Border.BorderBrush> <SolidColorBrush Color="{Binding ElementName=Border, Path=Background.Color}" /> </Border.BorderBrush> - Doug > I am trying to databind a color to a Border control. > The goal is to have the border as 100% opaque and the background > filled with > the same color, but with only 10% opacity. > Here's the relevant XAML: > > <Border BorderThickness="2" Padding="2"> > > <Border.BorderBrush> > <SolidColorBrush Color="{Binding Owner.Color}" /> > </Border.BorderBrush> > <Border.Background> > <SolidColorBrush Color="{Binding Owner.Color}" Opacity="0.1" /> > </Border.Background> > .... > > Now the result is really confusing. The Background is filled > correctly, but the border is transparent!!! > > I see 2 things which could go wrong: > 1. The databinding is not working (wrong Path, null object, whatever). > But > this is obviously not the case, since the Background - which uses the > very > same binding - is working perfectly! > 2. The BorderBrush doesn't work like I think it does. But just > replacing the > binding expression with a constant "Red" works flawlessly. So it's > probably > alright too. > Can you guess what can go wrong with such a simple example ? Is this a > bug in WPF ? > |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Databinding not working on Borders ? Thank you for the suggestion. Unfortunately, binding the border directly to the background doesn't seem to work either. I guess that there is something broken in the databinding mechanism. I indeed see one error in the output, but I can't figure out what it means: Cannot find mentor for target element. 'BindingExpression':Path='Owner.Color'; DataItem=''null''; target element is ''SolidColorBrush' (hashcode='18783768')'; target property is 'Color' (type 'Color'); What surprises me most is the DataItem="null" ?? I mean: the background IS working, isn't it ? And what is this "mentor" ? BTW, I've tried another workaround (which doesn't work either). I wanted to directly databind the BorderBrush attribute: <Border BorderBrush="{Bind Owner.Color}" ...> A message in the output indicates that it doesn't work because there's no default converter from Color to Brush (of course). But the message clearly indicates that the binding is working: '#FF008000' value produced by BindingExpression is not valid for target property I'm clueless. |
My System Specs![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Borders in Excel | PowerShell | |||
| Printing borders | Vista print fax & scan | |||
| Touchpad Corners & Borders | Vista General | |||
| Program borders | Vista General | |||
| Transparent Windows - Not Borders???? | Vista General | |||