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

Load xml data into 1 ComboBox and 1 TextBox

$
0
0

Terms.xml ----

<?xml version="1.0" encoding="utf-8" ?>
<Terms>
<Item Name="Muddy" Surname="Waters" />
<Item Name="Roy" Surname="Buchanan" />
</Terms>

-----------------

xaml ---------

<Window.Resources>
<XmlDataProvider
x:Key="XmlData"
Source="d:\Terms.xml"
XPath="Terms" />
</Window.Resources>
<Grid>
<ComboBox
x:Name="ComboBox1"
IsEditable="True"
ItemsSource="{Binding Source={StaticResource XmlData}, XPath=./Item}"
DisplayMemberPath="@Name"
SelectionChanged="ComboBox1_SelectionChanged"
Width="240"
Grid.Column="0"
Grid.Row="0"
Height="25"
HorizontalAlignment="Left"
VerticalAlignment="Stretch"
Margin="20,50,0,0"/>
<TextBox
x:Name="TextBox1"
Width="240"
Height="25"
Grid.Column="0"
Grid.Row="0"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
Margin="20,70,0,80" />
</Grid>

-------------------------------------------------

I'd like to make TextBox1 display the Surname of the corresponding Name once selected in Combobox1.

Any suggestions?

 



Viewing all articles
Browse latest Browse all 18858

Trending Articles



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