Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

wpf listbox binding XElement not updated on add XElement

$
0
0

Hello,

I am a beginner in C# / xaml and I do not understand everything in the binding, among others if it is necessary to notify or not to refresh the view.

In my code I use XML and XElement to store data. The xml contains one list of items (Properties), each of these items contains two lists (videoStreams and audioStreams).

When I add (or delete) one video the view is not refreshed. After if I add (or delete) one audio the view is refershed. The videos and audios lists are updated. If, in the xaml code, I reverse audio and video lists, the problem is with audio. It's always the first xaml list which doesn't work

Have you any idea about this problem? Why two lists are updated and not the other. 

My XML (extract)


<Root><Properties name="Node"><videoNode exclude="false"><rate minFrameRate="" maxFrameRate="" /></videoNode><audioNode ><bitrateRange min="" max="" /></audioNode></Properties>

The xaml

<ListBox Name="rootList" ItemsSource ="{Binding Elements[Properties]}"><ListBox.ItemTemplate><DataTemplate><StackPanel><ListBox Name="videoStreams" ItemsSource="{Binding Elements[videoNode]}"><ListBox.ItemTemplate><DataTemplate><StackPanel x:Name="stackVideo" Orientation="Vertical"></StackPanel></DataTemplate></ListBox.ItemTemplate></ListBox><ListBox Name="audioStreams" ItemsSource="{Binding Elements[audioNode]}"><ListBox.ItemTemplate><DataTemplate><StackPanel x:Name="stackAudio" Orientation="Vertical"></StackPanel></DataTemplate></ListBox.ItemTemplate></ListBox></StackPanel></DataTemplate></ListBox.ItemTemplate></ListBox>

and the add function


foreach (XElement childElement in oMMPNode.Descendants("Properties")) { if (childElement.Attribute("id").Value == profileId) { XElement newVideo = new XElement("videoNode"); childElement.Add(newVideo); break; } }



Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>