本文整理汇总了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();
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
}
示例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);
}
示例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();
}
}