我想从另一个按钮样式绑定到一个按钮样式

发布于 2024-12-04 19:38:25 字数 122 浏览 1 评论 0原文

我需要在两个按钮之间做出某种考虑。我需要它们始终具有相同的样式..我知道滑动滑块时可以更改单词的字体大小..现在我需要应用类似的东西,但使用按钮的样式。 我正在寻找 XAML 上的一些东西,如果可能的话,不要通过 C# 来完成它!

I need to make some kind of minding between two buttons. I need that they always have the same style.. I know I can change the fontsize of a word when sliding a slider.. now I need to apply something like that but with the style of the buttons.
I'm looking something on XAML for not to do it through C# if possible!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

渔村楼浪 2024-12-11 19:38:25

您可以在双向模式下绑定两个按钮。

    <UserControl.Resources>
        <Style x:Key="btnStyle1">
            <Setter Property="Button.Foreground" Value="Red" />
        </Style>
        <Style x:Key="btnStyleTriggers">
            <Style.Triggers>
                <Trigger Property="Button.IsMouseOver" Value="True">
                    <Setter Property="Button.Foreground" Value="Blue" />
                </Trigger>
            </Style.Triggers>
        </Style>

    </UserControl.Resources>
    <Grid>
        <StackPanel>
            <Button Name="btn1" Content="Text" Style="{Binding ElementName=btn2, Path=Style, Mode=TwoWay}" />
            <Button Name="btn2" Content="Text"/>
        </StackPanel>
    </Grid>

当其中一个按钮的样式属性发生更改时,其他按钮的样式也会随之更改。

You can bind two button in two way mode.

    <UserControl.Resources>
        <Style x:Key="btnStyle1">
            <Setter Property="Button.Foreground" Value="Red" />
        </Style>
        <Style x:Key="btnStyleTriggers">
            <Style.Triggers>
                <Trigger Property="Button.IsMouseOver" Value="True">
                    <Setter Property="Button.Foreground" Value="Blue" />
                </Trigger>
            </Style.Triggers>
        </Style>

    </UserControl.Resources>
    <Grid>
        <StackPanel>
            <Button Name="btn1" Content="Text" Style="{Binding ElementName=btn2, Path=Style, Mode=TwoWay}" />
            <Button Name="btn2" Content="Text"/>
        </StackPanel>
    </Grid>

When one of the buttons style property changes the others style will follow it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文