by Jim
Jun 12, 2008 8:18 AM
The Visual Studio designer doesn't show the contents of a viewbox. I've got entire pages in viewboxes, so this is inconvenient...
I've just realized that this problem can be solved by creating a template for the page, in App.xaml:
<Style x:Key="viewboxedPage" TargetType="Page">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Page" >
<Viewbox Stretch="Fill">
<ContentPresenter
Content="{TemplateBinding ContentControl.Content}"
ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}"
Margin="{TemplateBinding Control.Padding}"
SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}"
/>
</Viewbox>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
The designer doesn't try to render a dynamic resource template at design time, so you're free to edit the contents of the page. Presumably this would work with user controls or other containers that use a viewbox.