Is there a way to preview GUI in a DataTemplate? e.g. if I have a Resource Dictionary, containing a DataTemplate, and the Data template contains GUI code, like
<DataTemplate x:Key="MyTemplate">
<StackPanel>
<TextBox Text="AAA"/>
</StackPanel>
</DataTemplate>
Can I view just the stackpanel? (like previewing a UserControl in design view). If not possible with original VS, is there a plugin for that?
Design-time data is mock data you set to make your controls easier to visualize in the XAML Designer.
Tip You can create a resource dictionary file in Microsoft Visual Studio by using the Add > New Item… > Resource Dictionary option from the Project menu. Here, you define a resource dictionary in a separate XAML file called Dictionary1. xaml.
In Extensible Application Markup Language (XAML), the ResourceDictionary class is typically an implicit collection element that is the object element value of several Resources properties, when given in property element syntax. For details on implicit collections in XAML, see XAML Syntax Terminology.
A resource dictionary is a repository for XAML resources, such as styles, that your app uses. You define the resources in XAML and can then retrieve them in XAML using the {StaticResource} markup extension and {ThemeResource} markup extension s. You can also access resources with code, but that is less common.
If you reference your template down in the body of your control, such as ItemTemplate="{StaticResource MyTemplate}"
, you can place your cursor on the name of the template and press F12 to have Visual Studio render the template in the XAML designer.
For some reason, this only works once. You have to close and reopen the form to see another template rendered. Surely there's some way to avoid this but I haven't been able to figure it out.
Visual Studio doesn't support doing this, but Expression Blend does, if you can get access to it. Here's some instructions on several ways to edit template resources:
http://msdn.microsoft.com/en-us/library/cc294908(v=expression.40).aspx
In particular, if you'd like to edit a DataTemplate located in a ResourceDictionary you would:
I know this an old question but I hope this helps!
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