wpf XMLDataProvider

csharp 复制代码
 <Window.Resources>
     <!--Data Template-->
     <DataTemplate DataType="Ut">
         <Grid>
             <StackPanel Orientation="Horizontal">
                 <Grid>
                     <Rectangle Stroke="Yellow" Fill="Orange" Width="{Binding XPath=@Price}"/>
                     <TextBlock Text="{Binding XPath=@Year}"/>
                 </Grid>
                 <TextBlock Text="{Binding XPath=@Price}" Margin="5.0"/>
             </StackPanel>
         </Grid>
     </DataTemplate>
     <XmlDataProvider x:Key="ds" XPath="Units/Unit/Ut">
         <x:XData>
             <Units xmlns="">
                 <Unit Year="2001" Price="100">
                     <Ut Year="3001" Price="300"></Ut>
                 </Unit>
                 <Unit Year="2001" Price="120"/>
                 <Unit Year="2001" Price="140"/>
                 <Unit Year="2001" Price="160"/>
                 <Unit Year="2001" Price="180"/>
                 <Unit Year="2001" Price="200"/>
             </Units>
         </x:XData>
     </XmlDataProvider>
 </Window.Resources>
 <Grid >

     <StackPanel>
         <ListBox ItemsSource="{Binding Source={StaticResource ds}}"/>
         <ComboBox ItemsSource="{Binding Source={StaticResource ds}}" Margin="5"/>
     </StackPanel>
 </Grid>
csharp 复制代码
 <Window.Resources>
         <!--<XmlDataProvider x:Key="ItemsDataProvider" XPath="/Items/Item">
             <x:XData>
                 <Items xmlns="">
                     <Item>Item1</Item>
                     <Item>Item2</Item>
                     <Item>Item3</Item>
                 </Items>
             </x:XData>
         </XmlDataProvider>-->
     <XmlDataProvider x:Key="ItemsDataProvider" XPath="/Items/Item" Source="./DataSources/XMLFile1.xml">
         
     </XmlDataProvider>
     </Window.Resources>
     <Grid>
         <ComboBox  ItemsSource="{Binding Source={StaticResource ItemsDataProvider}}" />
     </Grid>
相关推荐
5***a97515 小时前
后端配置中心选型,Nacos与Apollo
wpf
·心猿意码·15 小时前
WPF转换器机制
wpf
她说彩礼65万18 小时前
WPF命令
wpf
玖笙&21 小时前
✨WPF编程进阶【7.3】集成动画(附源码)
c++·c#·wpf·visual studio
ifeng09181 天前
鸿蒙分布式调试挑战:跨设备数据流转与连接稳定性
分布式·wpf·harmonyos
Macbethad2 天前
如何使用WPF做工控主页
wpf
Aevget2 天前
DevExpress WPF中文教程:Data Grid - Service(服务)示例
wpf·界面控件·devexpress·ui开发
Macbethad2 天前
WPF工控软件的设计方案
wpf
Macbethad4 天前
使用WPF编写一个读取串口的程序
wpf
Macbethad5 天前
如何用WPF做工控设置界面
java·开发语言·wpf