当前位置: 首页>>代码示例>>C#>>正文


C# DataGrid.SetValue方法代码示例

本文整理汇总了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;
        }
开发者ID:JohnDMathis,项目名称:Pippin,代码行数:11,代码来源:DataGridSelect.cs

示例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));
        }
开发者ID:JohanLarsson,项目名称:Gu.Wpf.DataGrid2D,代码行数:18,代码来源:ItemsSourceTests.cs

示例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));
        }
开发者ID:JohanLarsson,项目名称:Gu.Wpf.DataGrid2D,代码行数:22,代码来源:ItemsSourceTests.cs

示例4: SetDataGridRollbackOnDataContextChanged

 public static void SetDataGridRollbackOnDataContextChanged(DataGrid datagrid, bool value)
 {
     datagrid.SetValue(DataGridRollbackOnDataContextChangedProperty, value);
 }
开发者ID:Easy-DDI-Organizer,项目名称:EDO,代码行数:4,代码来源:DataGridRollbackOnDataContextChangedBehaviour.cs

示例5: SetIsEnableColumnsVisibility

 public static void SetIsEnableColumnsVisibility(DataGrid grid, bool value)
 {
     grid.SetValue(IsEnableColumnsVisibilityProperty, value);
 }
开发者ID:MaxGaranin,项目名称:WpfSamples,代码行数:4,代码来源:ColumnsVisibilityControl.xaml.cs

示例6: SetIsUpdatingColumnSettings

 private static void SetIsUpdatingColumnSettings(DataGrid dataGrid, bool value)
 {
     dataGrid.SetValue(IsUpdatingColumnSettingsPropertyKey, value);
 }
开发者ID:ruisebastiao,项目名称:Elysium-Extra,代码行数:4,代码来源:DataGridAttached.cs

示例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);
        }
开发者ID:aelij,项目名称:svcperf,代码行数:31,代码来源:QueryWindow.xaml.cs

示例8: SetIsColumnSettingsEnabled

 public static void SetIsColumnSettingsEnabled(DataGrid dataGrid, bool value)
 {
     dataGrid.SetValue(IsColumnSettingsEnabledProperty, value);
 }
开发者ID:ruisebastiao,项目名称:Elysium-Extra,代码行数:4,代码来源:DataGridAttached.cs

示例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);
 }
开发者ID:ruisebastiao,项目名称:Elysium-Extra,代码行数:10,代码来源:DataGridAttached.cs

示例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);
        }
开发者ID:barnstws,项目名称:Gu.Wpf.DataGrid2D,代码行数:15,代码来源:Selected.cs

示例11: SetColumnSettings

 public static void SetColumnSettings(DataGrid dataGrid, string value)
 {
     dataGrid.SetValue(ColumnSettingsProperty, value);
 }
开发者ID:ruisebastiao,项目名称:Elysium-Extra,代码行数:4,代码来源:DataGridAttached.cs

示例12: SetLastColumnFill

 public static void SetLastColumnFill(DataGrid element, bool value)
 {
     element.SetValue(LastColumnFillProperty, value);
 }
开发者ID:Blackjack92,项目名称:TimeManagement,代码行数:4,代码来源:DataGridExtensions.cs

示例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);
 }
开发者ID:barnstws,项目名称:Gu.Wpf.DataGrid2D,代码行数:6,代码来源:Selected.cs

示例14: SetDataGridMiddleButtonScroll

		public static void SetDataGridMiddleButtonScroll(DataGrid datagrid, bool value)
		{
			datagrid.SetValue(DataGridMiddleButtonScrollProperty, value);
		}
开发者ID:xbadcode,项目名称:Rubezh,代码行数:4,代码来源:DataGridProperties.cs

示例15: SetIsSelectionFixEnabled

		public static void SetIsSelectionFixEnabled(DataGrid element, bool value)
		{
			element.SetValue(IsSelectionFixEnabledProperty, value);
		}
开发者ID:xbadcode,项目名称:Rubezh,代码行数:4,代码来源:DataGridSingleRowSelected.cs


注:本文中的System.Windows.Controls.DataGrid.SetValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。