Freezable.Freeze 方法
定义
重载
Freeze() |
使当前对象不可修改,并且将其 IsFrozen 属性设置为 |
Freeze(Freezable, Boolean) |
如果 |
Freeze()
public:
void Freeze();
public void Freeze ();
member this.Freeze : unit -> unit
Public Sub Freeze ()
例外
注解
若要避免在 InvalidOperationException 调用此方法时出现的可能性,请检查 CanFreeze 属性以确定是否 Freezable 可以在调用此方法之前将其变为不可修改。To avoid the possibility of an InvalidOperationException when calling this method, check the CanFreeze property to determine whether the Freezable can be made unmodifiable before calling this method.
继承者说明
此方法使用 FreezeCore(Boolean) 方法使 Freezable 不可修改。This method uses the FreezeCore(Boolean) method to make the Freezable unmodifiable. 若要修改冻结行为,请重写 FreezeCore(Boolean) 方法。To modify freezing behavior, override the FreezeCore(Boolean) method.
另请参阅
适用于
Freeze(Freezable, Boolean)
如果 isChecking
参数为 true
,则此方法指示是否可将指定的 Freezable 变为不可修改。If the isChecking
parameter is true
, this method indicates whether the specified Freezable can be made unmodifiable. 如果 isChecking
参数为 false
,则此方法尝试将指定的 Freezable 变为不可修改,并指示操作是否成功。If the isChecking
parameter is false
, this method attempts to make the specified Freezable unmodifiable and indicates whether the operation succeeded.
protected public:
static bool Freeze(System::Windows::Freezable ^ freezable, bool isChecking);
protected internal static bool Freeze (System.Windows.Freezable freezable, bool isChecking);
static member Freeze : System.Windows.Freezable * bool -> bool
Protected Friend Shared Function Freeze (freezable As Freezable, isChecking As Boolean) As Boolean
参数
- freezable
- Freezable
要检查或要变为不可修改的对象。The object to check or make unmodifiable. 如果 isChecking
为 true
,则检查此对象,以确定是否可将其变为不可修改。If isChecking
is true
, the object is checked to determine whether it can be made unmodifiable. 如果 isChecking
为 false
,则在可能的情况下将此对象变为不可修改。If isChecking
is false
, the object is made unmodifiable, if possible.
- isChecking
- Boolean
若为 true
,则返回是否可冻结对象的指示(不实际冻结对象);若为 false
,则实际冻结对象。true
to return an indication of whether the object can be frozen (without actually freezing it); false
to actually freeze the object.
返回
当 isChecking
为 true
时,如果可以将指定的 Freezable 变为不可修改,则此方法返回 true
;如果无法将其变为不可修改,则返回 false
。If isChecking
is true
, this method returns true
if the specified Freezable can be made unmodifiable, or false
if it cannot be made unmodifiable. 当 isChecking
为 false
时,如果指定的 Freezable 目前已经不可修改,则此方法返回 true
;如果无法将其变为不可修改,则返回 false
。If isChecking
is false
, this method returns true
if the specified Freezable is now unmodifiable, or false
if it cannot be made unmodifiable.
例外
如果 isChecking
为 false
,则表明将 freezable
变为不可修改的尝试已失败;对象目前处于未知状态(可能已将其部分冻结)。When isChecking
is false
, the attempt to make freezable
unmodifiable was unsuccessful; the object is now in an unknown state (it might be partially frozen).
注解
除非您是从派生的 Freezable ,并且重写方法,否则不要调用此方法 FreezeCore 。Do not call this method unless you are deriving from Freezable and overriding the FreezeCore method. 此方法可在方法中用于 FreezeCore 冻结自身对象的类数据成员 Freezable 。This method may be used in the FreezeCore method to freeze class data members that are themselves Freezable objects.
在 Freezable 已冻结 (不可修改) 的对象上,可以再次调用此方法。It is alright to call this method again on a Freezable object that is already frozen (unmodifiable).
继承者说明
此方法使用 FreezeCore(Boolean) 方法使 Freezable 不可修改。This method uses the FreezeCore(Boolean) method to make the Freezable unmodifiable. 若要修改冻结行为,请重写 FreezeCore(Boolean) 方法。To modify freezing behavior, override the FreezeCore(Boolean) method.