随着项目界面的美观话,一般的window窗体样式已经满足不了现在的需求,所以需要我们自己定义window的样式。但是之前的窗口标题(WindowTitle)这个属性仍需体现。下面在保证自定义窗体样式的前提下,同时也需实现窗口标题这个需求提供实现方案。
首先我们需要创建自定义控件。创建一个ResourceDictionary.xaml 来定义window的样式。如代码:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Styles="clr-namespace:SmartRecognition.Styles">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/SmartRecognition.Styles;component/Brushes.xaml" />
</ResourceDictionary.MergedDictionaries>
<ControlTemplate x:Key="userWindowTemplate"
TargetType="{x:Type Styles:UserWindow}">
<Grid x:Name="grdLayRoot"
Margin="20"
Width="690"
Height="343">
<Viewbox x:Name="vbMain"
Stretch="Fill">
<Grid VerticalAlignment="Stretch"
HorizontalAlignment="Stretch">