0

我是新手XAML,我将如何Background Gradient BrushCanvas背景创建一个,Color Gradient可以使用先前定义Brush的来获得一个new Brush,如下所示:

<Style x:Key="CanvasColorTheme" TargetType="Canvas">
    <Setter Property="Background">
        <Setter.Value>
            <RadialGradientBrush>
                <GradientStop Color="#FFCCDFFF" Offset="0.25"/>
                <GradientStop <!-- Previous Color / 2 --> Offset="0.50"/>
                <GradientStop <!-- Previous Color / 2 --> Offset="0.70"/>
                <GradientStop <!-- Previous Color / 2 --> Offset="0.95"/>
            </RadialGradientBrush>
        </Setter.Value>                    
   </Setter>                
</Style>
4

1 回答 1

0

I used a ResourceDictionary. Here is what I have written inside:

 <LinearGradientBrush x:Key="ToolBarToggleButtonHorizontalBackground" EndPoint="0,1" StartPoint="0,0">
     <GradientStop Color="#ECECEC" Offset="0"/>
     <GradientStop Color="#DDDDDD" Offset="0.5"/>
     <GradientStop Color="#A0A0A0" Offset="1"/>
 </LinearGradientBrush>

<Style x:Key="ToolBarHorizontalOverflowButtonStyle" TargetType="{x:Type ToggleButton}">
     <Setter Property="Background" Value="{StaticResource ToolBarToggleButtonHorizontalBackground}"/>
</Style>

So as to "activate" the ResourceDictionary you must enter this code insode App.xaml

<Application.Resources>
     <ResourceDictionary>
         <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="Themes/ShinyGrey.xaml"/>
         </ResourceDictionary.MergedDictionaries>
     </ResourceDictionary>
 </Application.Resources>

hope it helps.

于 2013-06-10T18:08:49.160 回答