你的位置:首页 > ASP.net教程

[ASP.net教程]WPF绑定xml数据源


1.界面

<UserControl x:
mc:Ignorable="d"
Background="White"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<Grid.Resources>
<
</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.后台代码

public partial class AboutUsControl : UserControl
{
       public AboutUsControl()
       {
            InitializeComponent();
           
            doc.Load("AboutUS.
           
            provider.Document = doc;
            provider.XPath = @"/Note/Body";

        }
}