I am building a UserControl
that has several DependencyProperties
that I use for the bindings of the XAML of the control.
When I work with MVVM I normally create a design time ViewModel, because I find that way it is easier to setup the layout of my Views without having to run the application.
Is there a way to set design time
data to my dependency properties in an UserControl?
A dependency property can reference a value through data binding. Data binding works through a specific markup extension syntax in XAML, or the Binding object in code. With data binding, determination of the final property value is deferred until run time, at which time the value is obtained from a data source.
Common Language Runtime (CLR) properties can be used to define effect parameters that don't respond to runtime property changes. This article demonstrates using CLR properties to pass parameters to an effect.
Arguably the biggest feature of a dependency property is its built-in ability to provide change notification. The motivation for adding such intelligence to properties is to enable rich functionality directly from declarative markup.
In yourxaml
, define this
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
d:DataContext="{d:DesignInstance prefix:ViewModel}"
That should give you the properties in the ViewModel..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With