在DrawingBrush中设置Falloutvalue

时间:2016-03-30 00:11:33

标签: c# wpf xaml

我有画笔

<DrawingBrush x:Key="ICON" Viewbox="0,0,39.125,39.125" ViewboxUnits="Absolute">
    <DrawingBrush.Drawing>
        <GeometryDrawing Brush="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=uiEntityViews:BaseView}, Path=MeSiteColor, FallBackValue=Gray}" Geometry="F1M19.5625,0.999954C29.8144,0.999954 38.125,9.31053 38.125,19.5625 38.125,29.8142 29.8143,38.1249 19.5625,38.1249 9.31073,38.1249 1,29.8142 1,19.5625 1,9.31053 9.31064,0.999954 19.5625,0.999954z">
            <GeometryDrawing.Pen>
                <Pen DashCap="Square" EndLineCap="Flat" LineJoin="Round" MiterLimit="10" StartLineCap="Flat" Thickness="2">
                    <Pen.Brush>
                        <LinearGradientBrush EndPoint="0.849422,0.849423" StartPoint="0.150577,0.150578">
                            <GradientStop Color="#FF657783" Offset="0"/>
                            <GradientStop Color="White" Offset="0.146"/>
                            <GradientStop Color="#FF2C4758" Offset="1"/>
                        </LinearGradientBrush>
                    </Pen.Brush>
                    <Pen.DashStyle>
                        <DashStyle/>
                    </Pen.DashStyle>
                </Pen>
            </GeometryDrawing.Pen>
        </GeometryDrawing>
    </DrawingBrush.Drawing>
</DrawingBrush>

我想设置颜色的FallBackValue,如果绑定失败,可以说Gray。但是,使用上面的代码,我收到以下错误

Error 587 Unknown property 'FallBackValue' for type 'System.Windows.Data.Binding' encountered while parsing a Markup Extension

1 个答案:

答案 0 :(得分:1)

它是FallbackValue,而不是FallBackValue。 (注意案例的区别。)