如何设置XAML GeometryDrawing的样式?

时间:2015-12-17 15:22:03

标签: wpf xaml

我有一个XAML图标,如下所示。我将它用作Button的ImageSource的一部分。如何创建一个样式,以便我可以从我的Button传递Brush颜色,这样我可以使用相同图标的不同颜色?

<DrawingImage x:Key="ico_save">
        <DrawingImage.Drawing>
            <GeometryDrawing Brush="SteelBlue" Geometry="F1 M 20.5833,20.5833L 55.4167,20.5833L 55.4167,55.4167L 45.9167,55.4167L 45.9167,44.3333L 30.0833,44.3333L 30.0833,55.4167L 20.5833,55.4167L 20.5833,20.5833 Z M 33.25,55.4167L 33.25,50.6667L 39.5833,50.6667L 39.5833,55.4167L 33.25,55.4167 Z M 26.9167,23.75L 26.9167,33.25L 49.0833,33.25L 49.0833,23.75L 26.9167,23.75 Z" />
        </DrawingImage.Drawing>
    </DrawingImage>

以下是我如何使用它:

    <RibbonButton x:Name="RibbonButtonSave"
                                      Label="Save"
                                      LargeImageSource="{StaticResource ico_save}"
                                      ToolTip="Save as HTML" />

In order to have different colored-icons I want to be able to do something like this:

 <RibbonButton x:Name="RibbonButtonSaveRed"
                                      Label="Save"
                                      LargeImageSource="{StaticResource ico_save}"
Color="Red"
                                      ToolTip="Save as HTML" />


 <RibbonButton x:Name="RibbonButtonSaveBlue"
                                      Label="Save"
                                      LargeImageSource="{StaticResource ico_save}"
Color="Blue"
                                      ToolTip="Save as HTML" />

0 个答案:

没有答案