Hello,
Why databinding TwoWay don't work on the text property of a combobx in .net 4.0 (it's working in .net 3.5) ?
My code :
I have an xml file like this :
<xml>
<combobox option="" obs="tralala">
<option value="here" />
<option value="there" />
</combobox>
<combobox option="blue" obs="">
<option value="one" />
<option value="two" />
<option value="three" />
</combobox>
</xml>
and I have a ListItem
control like that :
<ListBox DataContext="{Binding UpdateSourceTrigger=PropertyChanged}"
ItemsSource="{Binding UpdateSourceTrigger=PropertyChanged}"
IsSynchronizedWithCurrentItem="True">
<ListBox.ItemTemplate>
<DataTemplate>
<DockPanel LastChildFill="True">
<ComboBox MinWidth="75" IsEditable="True"
IsReadOnly="False" DockPanel.Dock="Left"
DataContext="{Binding Path=Element[combobox ]}"
IsSynchronizedWithCurrentItem="False"
ItemsSource="{Binding Path=Elements[option], UpdateSourceTrigger=PropertyChanged}"
DisplayMemberPath="Attribute[value].Value"
Text="{Binding Path=Attribute[option].Value, UpdateSourceTrigger=PropertyChanged}"
/>
<TextBox MinWidth="150" AcceptsReturn="False"
AcceptsTab="False" TextWrapping="NoWrap"
Text="{Binding Path=Attribute[obs].Value, UpdateSourceTrigger=PropertyChanged}" />
</DockPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Here is the code behind :
XDocument xdXml;
public MyWindow()
{
xdXml = XDocument.Load(@"C:\file.xml");
InitializeComponent();
DataContext = xdXml;
xdXml.Changed += new EventHandler<XObjectChangeEventArgs>(XdXml_Changed);
}
private void XdXml_Changed(object sender, XObjectChangeEventArgs e)
{
xdXml.Save(@"C:\fichier.xml");
}
I do like that because i can have a ComboBox
with auto-completion with the différents custom option for each, but I can write what I want, and the result is in the attribute option of the element <combobox>
It work fine if I target .net 3.5, but only textbox bind if I target .net 4.0
Why ? What can I do ?
Thank you by advance for your help !