本文整理汇总了C#中System.Windows.Controls.DataGrid.GetCellValue方法的典型用法代码示例。如果您正苦于以下问题:C# DataGrid.GetCellValue方法的具体用法?C# DataGrid.GetCellValue怎么用?C# DataGrid.GetCellValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.DataGrid
的用法示例。
在下文中一共展示了DataGrid.GetCellValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Array2DTransposed
public void Array2DTransposed()
{
var array = new[,] { { 1, 2 }, { 3, 4 }, { 5, 6 } };
var dataGrid = new DataGrid();
dataGrid.SetValue(ItemsSource.Array2DTransposedProperty, array);
dataGrid.Initialize();
Assert.IsInstanceOf<Array2DView>(dataGrid.ItemsSource);
Assert.AreEqual(3, dataGrid.Columns.Count);
Assert.AreEqual(2, dataGrid.Items.Count);
Assert.AreEqual(1, dataGrid.GetCellValue(0, 0));
Assert.AreEqual(3, dataGrid.GetCellValue(0, 1));
Assert.AreEqual(5, dataGrid.GetCellValue(0, 2));
Assert.AreEqual(2, dataGrid.GetCellValue(1, 0));
Assert.AreEqual(4, dataGrid.GetCellValue(1, 1));
Assert.AreEqual(6, dataGrid.GetCellValue(1, 2));
}
示例2: RowsSource
public void RowsSource()
{
var ints = new ObservableCollection<ObservableCollection<int>>
{
new ObservableCollection<int>(new[] { 1, 2 }),
new ObservableCollection<int>(new[] { 3, 4 }),
new ObservableCollection<int>(new[] { 5, 6 })
};
var dataGrid = new DataGrid();
dataGrid.SetValue(ItemsSource.RowsSourceProperty, ints);
dataGrid.Initialize();
Assert.IsInstanceOf<Lists2DView>(dataGrid.ItemsSource);
Assert.AreEqual(1, dataGrid.GetCellValue(0, 0));
Assert.AreEqual(2, dataGrid.GetCellValue(0, 1));
Assert.AreEqual(3, dataGrid.GetCellValue(1, 0));
Assert.AreEqual(4, dataGrid.GetCellValue(1, 1));
Assert.AreEqual(5, dataGrid.GetCellValue(2, 0));
Assert.AreEqual(6, dataGrid.GetCellValue(2, 1));
}
示例3: TransposedSource
public void TransposedSource()
{
var persons = new ObservableCollection<Person> { new Person { FirstName = "Johan", LastName = "Larsson" } };
var dataGrid = new DataGrid();
dataGrid.SetValue(ItemsSource.TransposedSourceProperty, persons);
dataGrid.Initialize();
var itemsSource = dataGrid.ItemsSource;
Assert.IsInstanceOf<TransposedItemsSource>(itemsSource);
Assert.AreEqual(2, dataGrid.Columns.Count);
Assert.AreEqual(2, dataGrid.Items.Count);
Assert.AreEqual("FirstName", dataGrid.GetCellValue(0, 0));
Assert.AreEqual("Johan", dataGrid.GetCellValue(0, 1));
Assert.AreEqual("LastName", dataGrid.GetCellValue(1, 0));
Assert.AreEqual("Larsson", dataGrid.GetCellValue(1, 1));
persons.Add(new Person { FirstName = "Erik", LastName = "Svensson" });
Assert.AreNotSame(itemsSource, dataGrid.ItemsSource);
Assert.AreEqual(3, dataGrid.Columns.Count);
Assert.AreEqual(2, dataGrid.Items.Count);
/*
Assert.AreEqual("FirstName", dataGrid.GetCellValue(0, 0));
Assert.AreEqual("Johan", dataGrid.GetCellValue(0, 1));
Assert.AreEqual("Erik", dataGrid.GetCellValue(0, 2));
Assert.AreEqual("LastName", dataGrid.GetCellValue(1, 0));
Assert.AreEqual("Larsson", dataGrid.GetCellValue(1, 1));
Assert.AreEqual("Svensson", dataGrid.GetCellValue(1, 2));
*/
}