更新 : 2007 年 11 月
編集ストアに対する変更グループを表します。
名前空間 : Microsoft.Windows.Design.Model
アセンブリ : Microsoft.Windows.Design.Interaction (Microsoft.Windows.Design.Interaction.dll 内)
構文
'宣言
Public MustInherit Class ModelEditingScope _
Implements IDisposable
'使用
Dim instance As ModelEditingScope
public abstract class ModelEditingScope : IDisposable
public ref class ModelEditingScope abstract : IDisposable
public abstract class ModelEditingScope implements IDisposable
解説
変更グループはトランザクションです。編集スコープで加えられた変更は、1 つの単位としてコミットまたは中止できます。
編集スコープがコミットされると、編集ストアは発生したすべての変更を受け入れ、モデルに適用します。Complete メソッドが呼び出される前に、編集スコープの Revert メソッドが呼び出されるか、または編集スコープが破棄されると、編集スコープは、基になるオブジェクトに加えられた変更を元に戻し、編集ストアから状態を再適用します。これにより、取り消しメカニズムが強固になります。
編集スコープは、using ステートメントまたは try/finally ブロックで常にラップします例外が発生すると、Dispose メソッドの呼び出しで変更が中止されます。
例
' The SetHeightAndWidth utility method sets the Height and Width
' properties through the model and commits the change.
Private Sub SetHeightAndWidth(ByVal [auto] As Boolean)
settingProperties = True
Dim batchedChange As ModelEditingScope = adornedControlModel.BeginEdit()
Try
Dim widthProperty As ModelProperty = adornedControlModel.Properties(Control.WidthProperty)
Dim heightProperty As ModelProperty = adornedControlModel.Properties(Control.HeightProperty)
If [auto] Then
widthProperty.ClearValue()
heightProperty.ClearValue()
Else
widthProperty.SetValue(20.0)
heightProperty.SetValue(20.0)
End If
batchedChange.Complete()
Finally
batchedChange.Dispose()
settingProperties = False
End Try
End Sub
// The SetHeightAndWidth utility method sets the Height and Width
// properties through the model and commits the change.
private void SetHeightAndWidth(bool autoSize)
{
settingProperties = true;
try
{
using (ModelEditingScope batchedChange = adornedControlModel.BeginEdit())
{
ModelProperty widthProperty =
adornedControlModel.Properties[Control.WidthProperty];
ModelProperty heightProperty =
adornedControlModel.Properties[Control.HeightProperty];
if (autoSize)
{
widthProperty.ClearValue();
heightProperty.ClearValue();
}
else
{
widthProperty.SetValue(20d);
heightProperty.SetValue(20d);
}
batchedChange.Complete();
}
}
finally { settingProperties = false; }
}
継承階層
System.Object
Microsoft.Windows.Design.Model.ModelEditingScope
スレッド セーフ
この型のすべてのパブリック static (Visual Basic では Shared) メンバは、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
参照
参照
Microsoft.Windows.Design.Model 名前空間