与DataGrid中的WPF应用程序处理 [英] Dealing with Datagrids in WPF Application

查看:122
本文介绍了与DataGrid中的WPF应用程序处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的需要这个帮助...

I Really need help in this ...

我要建在哪里,我需要有出头的DataGrid中的应用程序。

I'm building an application where I need to have somethings in the datagrid.

我想有数据网格有下拉列表,这些列表会会改变取决于其他下拉值,这也取决于previous值。我可以处理这个...

I want to have the datagrid to have drop-down lists, these lists will will change depending on other drop-down values, also depending on previous values. I can handle this ...

我想知道怎么知道如何创建数据网格,即如何添加列(静态),行(动态)。

I want to know how to know how to create the datagrid, i.e. how to add columns (statically), rows (dynamically).

主要地,该数据将被存储在XML文件中。

Mainly, the data will be stored in XML file.

推荐答案

您可以做这样的事情 -

You can do something like this -

//Load XML file and set the DataGrid data context
XElement mymusic = XElement.Load("mymusic.xml");
dg1.DataContext = mymusic.Elements("Album");

XAML中:

Xaml:

<toolkit:DataGrid Name="dg1" ItemsSource="{Binding}"  >
    <toolkit:DataGrid.Columns>
        <toolkit:DataGridTextColumn Header="Album Title" Binding="{Binding Path=Attribute[Title].Value}" HeaderStyle="{StaticResource MyHeaderStyle}" />
        <toolkit:DataGridTextColumn Header="Artist" Binding="{Binding Path=Attribute[Artist].Value}" HeaderStyle="{StaticResource MyHeaderStyle}"/>
        <toolkit:DataGridTextColumn Header="Release Date" Binding="{Binding Path=Attribute[ReleaseDate].Value}" HeaderStyle="{StaticResource MyHeaderStyle}" />
    </toolkit:DataGrid.Columns>
</toolkit:DataGrid>

查看这篇文章的详细信息 -

Check this article for more details -

使用XML数据的一个DataGrid样本

这篇关于与DataGrid中的WPF应用程序处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆