Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ComboBox binding to self
Message
From
28/01/2008 10:20:31
 
 
To
All
General information
Forum:
ASP.NET
Category:
Windows Presentation Foundation (WPF)
Title:
ComboBox binding to self
Miscellaneous
Thread ID:
01286103
Message ID:
01286103
Views:
68
Hi,

Should be a nobrainer but given a combobox defined in XAML as say:
<ComboBox Width="Auto" >
 	<ComboBoxItem Content="Apples" Foreground="Red" />
	<ComboBoxItem Content="Oranges" Foreground="Orange"/>
	<ComboBoxItem Content="Pears" Foreground="Green"/>
</ComboBox>
by default the value in the combobox when closed does not reflect the relevant ComboBoxItem.Foreground setting. I can fix this in code with:
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
    ComboBox.Foreground = ((ComboBoxItem)ComboBox.SelectedItem).Foreground;
        }
But how do I express this as a binding in XAML?
TIA,
Viv
Next
Reply
Map
View

Click here to load this message in the networking platform