I have the following window definition
<Window x:Class="MyWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Style="{StaticResource ShapedWindow}"
Title="Title">
<Grid Name="grid1" />
</Window>
with the following style and template definition
<Style x:Key="ShapedWindow" TargetType="{x:Type Window}">
<Setter Property="AllowsTransparency" Value="True"></Setter>
<Setter Property="WindowStyle" Value="None"></Setter>
<Setter Property="Background" Value="Transparent"></Setter>
<Setter Property="MinWidth" Value="300" />
<Setter Property="MinHeight" Value="300" />
<Setter Property="Template" Value="{StaticResource ShapedWindowTemplate}"></Setter>
</Style>
<ControlTemplate x:Key="ShapedWindowTemplate" TargetType="{x:Type Window}">
<!--<AdornerDecorator>
<ContentPresenter />
</AdornerDecorator>-->
</ControlTemplate>
which produces the following window in the designer
When I remove the comments from the template definition the grid doesn't seem to be rendered in the same position? What am I missing here?
I've seen this behavior in the VS2010 Designer a couple of times and I'm pretty sure it's a bug.
With an empty Template, there is nothing to render so you shouldn't be able to see the
Grid
at all. When you remove the comments in your ControlTemplate, the effect is most likely a bug in theVS2010 Designer
which happends everytime you set the Template for aWindow
so I don't think you're actually missing anything.It'll occur even if you use the default Window Template, created in Expression Blend
Here's a comparison between VS2010 Designer and Expression Blend 4 using the Default Template for a
Window
so as you can see, this really looks like a bugNote: The exact same thing happends when you use set the Template for a
GroupBox
, even if the ControlTemplate you set is identical to the default Template