2009-04-13 126 views
0

我有应用程序,其中默认的窗口边界关闭WPF店面布局资源

窗口标签的定义是这样的:

<Window x:Class="TEA.UI.MainWindow" 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
Title="Title" WindowStyle="None" AllowsTransparency="True" Background="Transparent"> 

窗口内部的标签,有网格面板,它包含几个矩形的形状和其他几个网格。

它看起来像这样:

<Grid> 
    <!-- WINDOW BACKGROUND --> 
    <Rectangle Stroke="#FF214E80" RadiusX="3" RadiusY="3" ClipToBounds="True"> 
     <Rectangle.Fill> 
      <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> 
       <GradientStop Color="#FF193C6C" Offset="0"/> 
       <GradientStop Color="#FF2A65A4" Offset="1"/> 
      </LinearGradientBrush> 
     </Rectangle.Fill> 
    </Rectangle> 
    <!-- // WINDOW BACKGROUND --> 

    <!-- HEADER HIGHLIGHT2 --> 
    <Rectangle HorizontalAlignment="Stretch" Margin="2,2,2,0" VerticalAlignment="Top" Height="62" RadiusX="2" RadiusY="2"> 
     <Rectangle.Fill> 
      <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> 
       <GradientStop Color="#00193C6C" Offset="1"/> 
       <GradientStop Color="#4C96ABC3" Offset="0"/> 
      </LinearGradientBrush> 
     </Rectangle.Fill> 
    </Rectangle> 
    <!-- // HEADER HIGHLIGHT2 --> 
<Grid> 
    .... 
</Grid> 

这些矩形形状,其在其他窗口对话框中使用。

我的问题是:

它是如何将有可能存储WPF资源字典里面这些recatangles?

我将如何能够引用它们?

回答

1

其实,解决方案是非常简单 WPF用户控件为我做的伎俩

0

您可以在资源字典中为这些项目创建样式,并为每个属性设置setter,其中一个包含在下面。

<Style TargetType="{x:Type Rectangle}" x:Key="WindowBackground"> 
    <Setter Property="Stroke" Value="#FF214E80"/> 
</Style> 

然后在窗口中可以参考的样式等..

<Rectangle Style="{StaticResource WindowBackground}"/> 
+0

谢谢你的回答,但是这将不得不为每个矩形创建单独的样式。 – 2009-04-13 18:22:26