Grid自帶顯示網格線ShowGridLines="True"。但是顯示出來的網格線能丑,我能不能自己去定義他呢?
如圖:
我的效果要求這樣。頭部改變背景色。網格線細小,不是虛線的形式!
解決辦法:
創建自定義Style就可以。
<UserControl xmlns="//schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="//schemas.microsoft.com/winfx/2006/xaml"
Width= "400" Height="400">
<UserControl.Resources>
<!-- A ContentControl template that defines your background -->
<ControlTemplate x:Key="BackgroundTemplate" TargetType="ContentControl">
<Grid>
<Border BorderBrush="Black" BorderThickness="2">
<Border.Background>
<LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
<GradientStop Color="Black" Offset="0.953" />
<GradientStop Color="White" Offset="0" />
</LinearGradientBrush>
</Border.Background>
</Border>
<Path Data="M 0,0 C 0,620 10,10 560,0" Height="60" VerticalAlignment="Top">
<Path.Fill>
<LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
<GradientStop Color="Black" Offset="0" />
<GradientStop Color="White" Offset="0.779" />
</LinearGradientBrush>
</Path.Fill>
</Path>
</Grid>
</ControlTemplate>
<!-- A ContentControl Style that references the background template -->
<Style x:Key="BackgroundStyle" TargetType="ContentControl">
<Setter Property="Template"
Value="{StaticResource BackgroundTemplate}" />
</Style>
</UserControl.Resources>
<!-- Typical usage;
place the background ContentControl behind your body content -->
<Grid x:Name="LayoutRoot">
標簽:
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:網絡轉載