本文整理汇总了C#中System.Windows.Controls.DataGrid.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# DataGrid.SetValue方法的具体用法?C# DataGrid.SetValue怎么用?C# DataGrid.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.DataGrid
的用法示例。
在下文中一共展示了DataGrid.SetValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetOrCreateBehavior
private static DataGridSelectCommandBehavior GetOrCreateBehavior(DataGrid selector)
{
var behavior = selector.GetValue(SelectCommandBehaviorProperty) as DataGridSelectCommandBehavior;
if (behavior == null)
{
behavior = new DataGridSelectCommandBehavior(selector);
selector.SetValue(SelectCommandBehaviorProperty, behavior);
}
return behavior;
}
示例2: 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));
}
示例3: 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));
}
示例4: SetDataGridRollbackOnDataContextChanged
public static void SetDataGridRollbackOnDataContextChanged(DataGrid datagrid, bool value)
{
datagrid.SetValue(DataGridRollbackOnDataContextChangedProperty, value);
}
示例5: SetIsEnableColumnsVisibility
public static void SetIsEnableColumnsVisibility(DataGrid grid, bool value)
{
grid.SetValue(IsEnableColumnsVisibilityProperty, value);
}
示例6: SetIsUpdatingColumnSettings
private static void SetIsUpdatingColumnSettings(DataGrid dataGrid, bool value)
{
dataGrid.SetValue(IsUpdatingColumnSettingsPropertyKey, value);
}
示例7: AddResultGrid
void AddResultGrid(IEnumerable items)
{
DataGrid grid = new DataGrid();
grid.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
grid.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
grid.SelectionUnit = DataGridSelectionUnit.Cell;
grid.Margin = new Thickness(10);
grid.HorizontalGridLinesBrush = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.LightBlue);
grid.VerticalGridLinesBrush = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.LightBlue);
grid.ItemsSource = items;
grid.BorderThickness = new Thickness(0);
grid.IsReadOnly = true;
grid.CanUserSortColumns = false;
grid.IsSynchronizedWithCurrentItem = true;
grid.EnableColumnVirtualization = true;
grid.SelectionMode = DataGridSelectionMode.Extended;
grid.SetValue(VirtualizingStackPanel.IsVirtualizingProperty, true);
grid.SetValue(VirtualizingStackPanel.VirtualizationModeProperty, VirtualizationMode.Recycling);
ContextMenu menu = new ContextMenu();
MenuItem menuitem = new MenuItem();
menuitem.Header = "Copy with headers";
menuitem.Command = new CopyWithHeadersCommand();
menuitem.CommandParameter = grid;
menu.Items.Add(menuitem);
grid.ContextMenu = menu;
this.ResultPanel.RowDefinitions.Add(new RowDefinition());
grid.SetValue(Grid.RowProperty, this.ResultPanel.RowDefinitions.Count - 1);
this.ResultPanel.Children.Add(grid);
}
示例8: SetIsColumnSettingsEnabled
public static void SetIsColumnSettingsEnabled(DataGrid dataGrid, bool value)
{
dataGrid.SetValue(IsColumnSettingsEnabledProperty, value);
}
示例9: SetIsSingleClickEdit
/// <summary>
/// Sets the edit cells with a single click mode.
/// By default a cell has to be double clicked to enter editing mode, this property changes this to be a single click.
/// </summary>
/// <param name="dataGrid">The data grid.</param>
/// <param name="value">if set to <c>true</c> edit cells with a single click.</param>
public static void SetIsSingleClickEdit(DataGrid dataGrid, bool value)
{
dataGrid.SetValue(IsSingleClickEditProperty, value);
}
示例10: UpdateSelectedCellItemFromView
private static void UpdateSelectedCellItemFromView(DataGrid dataGrid)
{
var index = dataGrid.GetIndex();
if (index == null || index.Value.Column < 0 || index.Value.Column >= dataGrid.Columns.Count)
{
dataGrid.SetValue(CellItemProperty, null);
return;
}
var column = dataGrid.Columns.ElementAtOrDefault<DataGridColumn>(index.Value.Column);
var item = dataGrid.Items.ElementAtOrDefault(index.Value.Row);
var cellItem = GetCellItem(column, item);
dataGrid.SetValue(CellItemProperty, cellItem);
}
示例11: SetColumnSettings
public static void SetColumnSettings(DataGrid dataGrid, string value)
{
dataGrid.SetValue(ColumnSettingsProperty, value);
}
示例12: SetLastColumnFill
public static void SetLastColumnFill(DataGrid element, bool value)
{
element.SetValue(LastColumnFillProperty, value);
}
示例13: SubscribeSelectionChanges
private static void SubscribeSelectionChanges(DataGrid dataGrid)
{
dataGrid.UpdateHandler(DataGridCell.SelectedEvent, SelectedCellsChangedHandler, true);
dataGrid.UpdateHandler(DataGridCell.UnselectedEvent, SelectedCellsChangedHandler, true);
dataGrid.SetValue(IsSubscribingChangesProperty, BooleanBoxes.True);
}
示例14: SetDataGridMiddleButtonScroll
public static void SetDataGridMiddleButtonScroll(DataGrid datagrid, bool value)
{
datagrid.SetValue(DataGridMiddleButtonScrollProperty, value);
}
示例15: SetIsSelectionFixEnabled
public static void SetIsSelectionFixEnabled(DataGrid element, bool value)
{
element.SetValue(IsSelectionFixEnabledProperty, value);
}