开发者

Bind to attached property in ControlTemplate - Silverlight

开发者 https://www.devze.com 2022-12-10 03:36 出处:网络
I have this style: <Style x:Key=\"ButtonStyle\" TargetType=\"Button\"> <Setter Property=\"Template\">

I have this style:

 <Style x:Key="ButtonStyle" TargetType="Button">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Grid>
                                        <StackPanel>
                           <Image Source="{Binding Path=local:AttachedProperties.Image}"  Stretch="None" HorizontalAlignment="Center" Margin="0" VerticalAlignment="Top"/>
                                <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignm开发者_StackOverflowent}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                            </StackPanel>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

The problem is that the binding does not work for a button:

<Button HorizontalAlignment="Center" Style="{StaticResource ButtonStyle}" VerticalAlignment="Center" Content="Button" local:AttachedProperties.Image="../Images/UserChart.png" Grid.RowSpan="2"/>

What I'm doing wrong?


By the sounds of it, this is a Silverlight issue. More information at this post:

http://forums.silverlight.net/forums/p/102737/299184.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号