I use PropertyGrid from WPF Toolkit and using default Editor. I want to set the default value using DefaultValue Attribute, but it doesn't work.
This is my model:
public class PropertyDummyViewModel : NotifyPropertyChanged
{
[DisplayName(@"Double Value Default Editor")]
[DefaultValue(70)]
public double DoubleValueDefaultEditor { get; set; }
}
The XAML of PropertyDummyView:
<Grid ...
x:Name="PropertyGrid">
<xctk:PropertyGrid SelectedObject="{Binding Path=DataContext, ElementName=PropertyGrid}" />
</Grid>
And the PropertyGrid is:
public void ShowDialog()
{
var model = new PropertyDummyViewModel();
var view = new PropertyDummyView() { DataContext = model };
var window = new Window() { Content = view };
window.ShowDialog();
}
When I run it, the value of the property is 0, instead of 70. How to set default value on Wpf Toolkit PropertyGrid control?