2013-11-25

Use the image in style setting

Environment :

In resource dictionary, load image in style

When new instance apply the style, previous control who applied this style will lost the image.



Solution :

Add x:Shared="False" for style


EX:
<Style TargetType="{x:Type BC:captionButtonMin}" BasedOn="{StaticResource styleCaptionButton}" x:Shared="False">
        <Setter Property="BorderThickness" Value="1,1,1,1"/>
        <Setter Property="CornerRadius" Value="0,0,0,4"/>
        <Setter Property="Content">
            <Setter.Value>
                <Image Source="/Resources/Images/captionButtonMIN.jpg" Width="12" Margin="0,4,0,0"/>
            </Setter.Value>
        </Setter>      
    </Style>



Weird :

x:Shared does not show up from Intellisense??

沒有留言:

張貼留言