WPF binds xml data sources and wpf binds xml data sources.
1. Interface
<UserControl x: Class = "HKDCMS. Client. Demo. UIViews. UIControls. AboutUsControl"
Xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Xmlns: x = "http://schemas.microsoft.com/winfx/2006/xaml"
Xmlns: mc = "http://schemas.openxmlformats.org/markup-compatibility/2006"
Xmlns: d = "http://schemas.microsoft.com/expression/blend/2008"
Xmlns: wf = "clr-namespace: System. Windows. Forms; assembly = System. Windows. Forms"
Mc: Ignorable = "d"
Background = "White"
D: DesignHeight = "300" d: DesignWidth = "300">
<Grid>
<Grid. Resources>
<XmlDataProvider x: Key = "AllItem" Source = "AboutUS. xml" XPath = "AboutUS"/>
</Grid. Resources>
<Grid DataContext = "{Binding Source = {StaticResource AllItem}, XPath = PackageCollection}">
<Grid. RowDefinitions>
<RowDefinition Height = "Auto"/>
<RowDefinition Height = "Auto"/>
</Grid. RowDefinitions>
<TextBlock Text = "{Binding XPath = PackageVersionTitle}" FontSize = "18" Margin = "2" Grid. Row = "0"> </TextBlock>
<TextBox TextWrapping = "Wrap" AcceptsReturn = "True" Name = "PackageVersionNameBox"
Text = "{Binding XPath = PackageVersionName}" IsReadOnly = "True" Grid. Row = "1" Margin = "5"/>
</Grid>
</Grid>
</UserControl>
2. Background code
Public partial class AboutUsControl: UserControl
{
Public AboutUsControl ()
{
InitializeComponent ();
XmlDocument doc = new XmlDocument ();
Doc. Load ("AboutUS. xml ");
XmlDataProvider provider = new XmlDataProvider ();
Provider. Document = doc;
Provider. XPath = @ "/Note/Body ";
}
}