You must provide designer data.
There are several ways to do this.
One of the easiest is to provide a DataContext in the XAML ad for the designer to use when rendering your page.
In the Xaml page declaration:
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" d:DataContext="{d:DesignInstance local:DesignerSampleData, IsDesignTimeCreatable=True}"
The sample data class must contain the data that your visual elements are associated with:
public class DesignerSampleData: INotifyPropertyChanged { public DesignerSampleData() { _sampleData = "My test string that will display in VS designer for preview"; } private String _sampleData; public String SampleData { get { return _sampleData; } set { if (value != _sampleData) { _sampleData = value; NotifyPropertyChanged("SampleData"); } } }
In xaml, it binds to SampleData:
<TextBlock Text="{Binding SampleData}" />
source share