Class ViewModelLocator
- Namespace
- Crystal.Avalonia
- Assembly
- Crystal.Avalonia.dll
Provides automatic ViewModel binding via an attached property. Independent of EnableViewLocator on the app options instance, which only gates ViewModel-first view location.
public class ViewModelLocator
- Inheritance
-
ViewModelLocator
- Inherited Members
Remarks
When AutoWireViewModel is set to True,
the system automatically resolves the corresponding ViewModel from the DI container
and assigns it to the control's DataContext.
Fields
AutoWireViewModelProperty
Identifies the AutoWireViewModelProperty attached property registration.
When set to True, the system automatically binds the corresponding ViewModel to the control's DataContext.
public static readonly AttachedProperty<bool> AutoWireViewModelProperty
Field Value
- AttachedProperty<bool>
Methods
GetAutoWireViewModel(Control)
Gets the AutoWireViewModel attached property value for the specified control.
public static bool GetAutoWireViewModel(Control element)
Parameters
elementControlThe control to query.
Returns
- bool
Trueif the control has automatic ViewModel binding enabled.
SetAutoWireViewModel(Control, bool?)
Sets the AutoWireViewModel attached property value for the specified control.
public static void SetAutoWireViewModel(Control element, bool? value)
Parameters
elementControlThe control to set.
valuebool?Whether to enable automatic binding.