Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Design Time Data for Dependency Properties?

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?

like image 310
Dzyann Avatar asked Feb 21 '14 19:02

Dzyann


People also ask

What are the dependency properties?

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.

What are CLR properties?

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.

What is the biggest feature of dependency property?

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.


1 Answers

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..

like image 85
123 456 789 0 Avatar answered Sep 20 '22 00:09

123 456 789 0