自一Control
所以你必須override
它的默認模板(ControlTemplate
)。
在源代碼中,您將看到兩個包含MdiChild控件樣式的xamls - Aero.xaml
和Luna.xaml
。源代碼可以看到here。只要擺脫StackPanel(ButtonsPanel)
包含按鈕和Grid(HeaderContent)
。
那電源WPF給我們,您可以自定義任何控制,給它不管你通過覆蓋其ControlTemplate
覺得自己像個樣子。
編輯
覆蓋您必須重新定義你的XAML的模板。你必須做的是create a style again in your Window resources, set the template for the control
,它會自動覆蓋默認的控制模板。只需複製粘貼here中的整個模板,然後移除我上面提到的StackPanel和Grid。
<Window.Resources>
<Style TargetType="{x:Type mdi:MdiChild}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<!-- Copy paste entire template here and
just remove the StackPanel and Grid -->
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
EDIT2
替換您ControlTemplate
與此禁用標題欄,但仍使你控制的拖動操作和調整大小的操作 -
<ControlTemplate TargetType="{x:Type mdi:MdiChild}">
<Border Name="BaseBorder" BorderThickness="1" CornerRadius="5,5,0,0"
Background="{StaticResource BackBorderBackgroundBrush}"
BorderBrush="{StaticResource BackBorderBrush}">
<Grid>
<Border Name="ContentBorder"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<ContentControl Content="{TemplateBinding Content}" />
</Border>
<Thumb Name="DragThumb" Height="20" Margin="0,0,40,0"
VerticalAlignment="Top" Opacity="0"/>
<Rectangle Name="LeftBorder" Width="1" HorizontalAlignment="Left"
RadiusX="9" RadiusY="9"
Fill="{StaticResource NearBorderBrush}" />
<Rectangle Name="TopBorder" Height="1" VerticalAlignment="Top"
RadiusX="9" RadiusY="9"
Fill="{StaticResource NearBorderBrush}" />
<Rectangle Name="RightBorder" Width="1" HorizontalAlignment="Right"
RadiusX="9" RadiusY="9"
Fill="{StaticResource FarBorderBrush}" />
<Rectangle Name="BottomBorder" Height="1" VerticalAlignment="Bottom"
RadiusX="9" RadiusY="9"
Fill="{StaticResource FarBorderBrush}" />
<Thumb Name="ResizeLeft" Width="6" HorizontalAlignment="Left"
Margin="0,6,0,6" Opacity="0" Cursor="SizeWE"
IsHitTestVisible="{TemplateBinding Resizable}" />
<Thumb Name="ResizeTop" Height="4" VerticalAlignment="Top"
Margin="6,0,6,0" Opacity="0" Cursor="SizeNS"
IsHitTestVisible="{TemplateBinding Resizable}" />
<Thumb Name="ResizeRight" Width="6" HorizontalAlignment="Right"
Margin="0,6,0,6" Opacity="0" Cursor="SizeWE"
IsHitTestVisible="{TemplateBinding Resizable}" />
<Thumb Name="ResizeBottom" Height="6" VerticalAlignment="Bottom"
Margin="6,0,6,0" Opacity="0" Cursor="SizeNS"
IsHitTestVisible="{TemplateBinding Resizable}" />
<Thumb Name="ResizeTopLeft" Width="6" Height="6"
HorizontalAlignment="Left" VerticalAlignment="Top" Opacity="0"
Cursor="SizeNWSE"
IsHitTestVisible="{TemplateBinding Resizable}" />
<Thumb Name="ResizeTopRight" Width="6" Height="6"
HorizontalAlignment="Right" VerticalAlignment="Top"
Opacity="0" Cursor="SizeNESW"
IsHitTestVisible="{TemplateBinding Resizable}" />
<Thumb Name="ResizeBottomRight" Width="6" Height="6"
HorizontalAlignment="Right" VerticalAlignment="Bottom"
Opacity="0" Cursor="SizeNWSE"
IsHitTestVisible="{TemplateBinding Resizable}" />
<Thumb Name="ResizeBottomLeft" Width="6" Height="6"
HorizontalAlignment="Left" VerticalAlignment="Bottom"
Opacity="0" Cursor="SizeNESW"
IsHitTestVisible="{TemplateBinding Resizable}" />
</Grid>
</Border>
</ControlTemplate>
你有沒有嘗試設置'WindowStyle '去'無'.. ?? –
當然,我有,沒有WindowStyle屬性,因爲MdiChild是一個控件而不是一個窗口。 –