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


C# ModelItem.BeginEdit方法代码示例

本文整理汇总了C#中ModelItem.BeginEdit方法的典型用法代码示例。如果您正苦于以下问题:C# ModelItem.BeginEdit方法的具体用法?C# ModelItem.BeginEdit怎么用?C# ModelItem.BeginEdit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ModelItem的用法示例。


在下文中一共展示了ModelItem.BeginEdit方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GenerateColumns

        // These methods are not used, but they are very useful when developing the Design experience
#if Development

        /// <summary>
        ///     Adds a default column for each property in the data source
        /// </summary>
        public static void GenerateColumns(ModelItem dataGridModelItem, EditingContext context)
        {
            using (ModelEditingScope scope = dataGridModelItem.BeginEdit(Properties.Resources.Generate_Columns))
            {

                // Set databinding related properties
                DataGridDesignHelper.SparseSetValue(dataGridModelItem.Properties[MyPlatformTypes.DataGrid.AutoGenerateColumnsProperty], false);

                // Get the datasource 
                object dataSource = dataGridModelItem.Properties[MyPlatformTypes.DataGrid.ItemsSourceProperty].ComputedValue;
                if (dataSource != null)
                {

                    foreach (ColumnInfo columnGenerationInfo in DataGridDesignHelper.GetColumnGenerationInfos(dataSource))
                    {

                        ModelItem dataGridColumn = null;

                        dataGridColumn = DataGridDesignHelper.CreateDefaultDataGridColumn(context, columnGenerationInfo);

                        if (dataGridColumn != null)
                        {
                            dataGridModelItem.Properties[MyPlatformTypes.DataGrid.ColumnsProperty].Collection.Add(dataGridColumn);
                        }
                    }
                }
                scope.Complete();
            }
        }
开发者ID:kvervo,项目名称:HorizontalLoopingSelector,代码行数:35,代码来源:DataGridActions.cs

示例2: RemoveColumns

 /// <summary>
 ///     Removes all columns from the DataGrid
 /// </summary>
 public static void RemoveColumns(ModelItem dataGridModelItem, EditingContext editingContext)
 {
     using (ModelEditingScope scope = dataGridModelItem.BeginEdit(Properties.Resources.Remove_Columns))
     {
         dataGridModelItem.Properties[MyPlatformTypes.DataGrid.ColumnsProperty].Collection.Clear();
         scope.Complete();
     }
 }
开发者ID:kvervo,项目名称:HorizontalLoopingSelector,代码行数:11,代码来源:DataGridActions.cs

示例3: InitializeDefaults

 public override void InitializeDefaults(ModelItem item)
 {
     using (ModelEditingScope batchedChange = item.BeginEdit("Creates Default Items"))
     {
         for (int j = 0; j < 2; j++)
         {
             ModelItem i = ModelFactory.CreateItem(item.Context, typeof(NavigationPaneItem), CreateOptions.InitializeDefaults, null);
             item.Properties["Items"].Collection.Add(i);
         }
         batchedChange.Complete();
     }
 }
开发者ID:zhengjin,项目名称:WindowDemo,代码行数:12,代码来源:RegisterMetadata.cs

示例4: EditPropertyBoundColumns

        /// <summary>
        ///     Opens the Edit Property-Bound Columns dialog for the given DataGrid
        /// </summary>
        public static void EditPropertyBoundColumns(ModelItem dataGridModelItem, EditingContext editingContext)
        {
            using (ModelEditingScope scope = dataGridModelItem.BeginEdit(Properties.Resources.ColumnsChanged))
            {
                PropertyColumnEditor ui = new PropertyColumnEditor(editingContext, dataGridModelItem);

                // Use Windows Forms to show the design time because Windows Forms knows about the VS message pump
                System.Windows.Forms.DialogResult result = DesignerDialog.ShowDesignerDialog(Properties.Resources.Edit_Property_Bound_Columns_Dialog_Title, ui);
                if (result == System.Windows.Forms.DialogResult.OK)
                {
                    scope.Complete();
                }
                else
                {
                    scope.Revert();
                }
            }
        }
开发者ID:kvervo,项目名称:HorizontalLoopingSelector,代码行数:21,代码来源:DataGridActions.cs

示例5: TranslatePropertyValue

        public override object TranslatePropertyValue(ModelItem item, PropertyIdentifier identifier, object value)
        {
            MessageBox.Show($"name: {identifier.Name}\r\n" +
                            $"value: {value}\r\n" +
                            $"type: {value?.GetType()}\r\n" +
                            $"item.View: {item.View}\r\n" +
                            $"item.GetCurrentValue(): {item.GetCurrentValue()}");
            if (identifier.DeclaringType == BackgroundPropertyIdentifier.DeclaringType)
            {
                using (var editingScope = item.BeginEdit())
                {
                    var button = item.GetCurrentValue() as Button;
                    button?.SetValue(Control.BackgroundProperty, value);
                }

                return value;
            }

            return base.TranslatePropertyValue(item, identifier, value);
        }
开发者ID:JohanLarsson,项目名称:DesigntimeBox,代码行数:20,代码来源:DesignTimeBackgroundProvider.cs

示例6: AddColumns

        /// <summary>
        ///     Add Columns based on the datasource
        /// </summary>
        private void AddColumns(ModelItem selectedDataGrid, EditingContext context) 
        {
            using (ModelEditingScope scope = selectedDataGrid.BeginEdit("Generate Columns")) 
            {
                // Set databinding related properties
                DataGridHelper.SparseSetValue(selectedDataGrid.Properties[DataGrid.AutoGenerateColumnsProperty], false);

                // Get the datasource 
                object dataSource = selectedDataGrid.Properties[ItemsControl.ItemsSourceProperty].ComputedValue;
                if (dataSource != null) 
                {
                    // Does WPF expose something like ListBindingHelper?
                    PropertyDescriptorCollection dataSourceProperties = System.Windows.Forms.ListBindingHelper.GetListItemProperties(dataSource);

                    foreach (PropertyDescriptor pd in dataSourceProperties) 
                    {
                        ModelItem dataGridColumn = null;
                        
                        dataGridColumn = DataGridHelper.CreateDefaultDataGridColumn(context, pd);

                        if (dataGridColumn != null) 
                        {
                            selectedDataGrid.Properties["Columns"].Collection.Add(dataGridColumn);
                        }
                    }
                }

                scope.Complete();
            }
        }
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:33,代码来源:DataGridMenuProvider.cs


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