因为它是一个Control
所以你必须使用override
它的默认模板(ControlTemplate
)。
在源代码中,您将看到两个 xamls -Aero.xaml
并Luna.xaml
包含 MdiChild 控件的样式。源代码可以在这里看到。只需摆脱StackPanel(ButtonsPanel)
包含按钮和Grid(HeaderContent)
.
这就是 WPF 为我们提供的强大功能,您可以自定义任何控件,通过覆盖它的ControlTemplate
.
编辑
要覆盖模板,您必须在 xaml 中重新定义它。你要做的是create a style again in your Window resources, set the template for the control
它会自动覆盖默认的控制模板。只需从此处复制粘贴整个模板,然后删除我上面提到的 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>
编辑2
用这个替换你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>