相关疑难解决方法(0)

WPF:在某个控件的Trigger中追逐另一个控件的属性

这是我的文本块.

    <Image x:Name:imgAnother/>

    <TextBlock>
        this is my text block
        <TextBlock.Style>
            <Style TargetType="TextBlock">
                <Setter Property="TextDecorations" Value="None"/>
                <Style.Triggers>
                    <Trigger Property="TextBlock.IsMouseOver" Value="True">
                        <Setter Property="Foreground" Value="RoyalBlue"/>
                        <!--I like to insert a code at here that changes another control's property...-->
                    </Trigger>
                    <Trigger Property="TextBlock.IsMouseOver" Value="False">
                        <Setter Property="Foreground" Value="#FF808080"/>
                        <!--..and this line too.-->
                   </Trigger>
                </Style.Triggers>                    
            </Style>
        </TextBlock.Style>
    </TextBlock>
Run Code Online (Sandbox Code Playgroud)

我喜欢制作一个xaml代码,它可以改变另一个控件的功能,比如"imgAnother".

我怎样才能做到这一点?

wpf xaml triggers styles

7
推荐指数
1
解决办法
1万
查看次数

标签 统计

styles ×1

triggers ×1

wpf ×1

xaml ×1