2009-04-13 84 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