WPF DataGrid 遍历 求WPF高手
小弟我用的是WPF,WPF中没有DataGrid,我用的是toolkit中的DataGrid,
在页面中用了toolkit/DataGrid中的DataGridCheckBoxColumn用于多选,
现在想遍历一下DataGrid,看看DataGridCheckBoxColumn列中有哪些选中了,
再把与之相对应选中的CODE拿出来,求方法或代码。
XAML代码
<Custom:DataGrid BorderBrush="Chocolate" Height="486.163" Width="397" Name="dgExam"
AutoGenerateColumns="False"
ColumnHeaderStyle="{StaticResource dgHeaderStyle}"
RowStyle="{StaticResource dgRowStyle}"
CellStyle="{StaticResource dgCellStyle}"
SelectionChanged="dgExam_SelectionChanged"
CanUserAddRows="False"
CanUserResizeRows="False"
IsReadOnly="True" SelectionMode="Extended" >
<Custom:DataGrid.Columns>
<Custom:DataGridCheckBoxColumn x:Name="AllowCheckbox" Header="选择" Width="30" Binding="{Binding ex_no}" ElementStyle="{DynamicResource NoBorderCheckBoxStyle}"
EditingElementStyle="{DynamicResource NoBorderCheckBoxStyle}" IsThreeState="True"> </Custom:DataGridCheckBoxColumn>
</Custom:DataGrid.Columns>
</Custom:DataGrid>
Binding="{Binding ex_no}" 中ex_no是我绑定了数据库中的字段,dgExam.itemssource = datatable;
求WPF高手
------解决方案--------------------
C# code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace SLAPPDemo
{
public partial class Page : UserControl
{
public static List<ListInformation> pageItems = null;
public Page()
{
InitializeComponent();
DataBind();
}
/// <summary>
/// 设置 DataGrid 的数据源
/// </summary>
private void DataBind()
{
this.dataGrid.ItemsSource = GetSpecifiedPage();
}
/// <summary>
/// 获取数据源
/// </summary>
private List<ListInformation> GetSpecifiedPage(