Answer the question
In order to leave comments, you need to log in
Binding an xml file nested in a WPF ListView form?
Hello.
In a WPF project, I am loading an xml file from a remote server via http.
The structure is like this:
<subscribers>
<subscriber>
<fullname>FullName</fullname>
<positionName>PositionName</positionName>
<departamentName>DepartamentName</departamentName>
<contacts>
<contact type="Cell">Cell Number</contact>
<contact type="E-Mail">[email protected]</contact>
<contact type="Address">Country, Town, str</contact>
</contacts>
</subscriber>
<subscriber>
<fullname>FullName</fullname>
<positionName>PositionName</positionName>
<departamentName>DepartamentName</departamentName>
<contacts>
<contact type="Cell">Cell Number</contact>
<contact type="E-Mail">[email protected]</contact>
<contact type="Address">Country, Town, str</contact>
</contacts>
</subscriber>
</subscribers>
<ScrollViewer HorizontalAlignment="Stretch" Margin="10,50,10,10" VerticalAlignment="Stretch" VerticalScrollBarVisibility="Auto">
<Grid x:Name="SubscribersGrid" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0,0,0,0">
<ListView x:Name="SubscribersList" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0,0,0,0" Opacity="0.8" BorderThickness="0" ItemsSource="{Binding}">
<ListView.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300" />
<ColumnDefinition Width="350" />
<ColumnDefinition Width="400" />
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding XPath=fullname}" Grid.Column="0" />
<TextBlock Text="{Binding XPath=positionName}" Grid.Column="1" />
<Grid Grid.Column="2">
<ListView x:Name="ContactsList" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0,0,0,0" Opacity="0.8" BorderThickness="0" ItemsSource="{??????????????????????????????}">
<ListView.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition Width="100" />
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding [email protected]}" Grid.Column="0" />
<TextBlock Text="{Binding XPath=contact}" Grid.Column="1" />
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</ScrollViewer>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question