扳机未触发

发布于 2024-11-26 23:14:29 字数 169 浏览 2 评论 0 原文

一整天都在对此进行尝试和错误。我认为最好在这里发帖并获得一些关于我这样做是否正确的反馈。我只是想在选中单选按钮时更改 TextBlock ToolTip 文本。

编辑:弄清楚了...我将触发器应用于 DataTemplate 而不是 TextBlock 本身。 (见答案)

Been doing trial and error on this all day. Thought it might be better to post here and get some feedback on whether I am doing this the right way or not. I am just trying to change the TextBlock ToolTip text when the radio button is checked.

Edit: Figured it out... I applied the Trigger to the DataTemplate instead of the TextBlock itself. (See answer)

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

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

发布评论

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

评论(1

夜清冷一曲。 2024-12-03 23:14:29

如果您在本地设置文本,触发器将无法更改该值,因为 优先级

将默认文本移至样式中:

<!-- There are still issues with this -->
<TextBlock Grid.Row="2" Grid.Column="1">
    <TextBlock.Style>
        <Style TargetType="{x:Type TextBlock}">
            <Setter Property="Text" Value="{Binding SIMULATOR_CONTROL_BLADE_DATA.CONTROL_BLADE_ASSEMBLY.REACTOR_CORE_COORDINATE.RCC_REACTOR_Y}"/>
            <Style.Triggers>
                <DataTrigger Binding="{Binding radSimulator, Path=IsChecked}" Value="True">
                    <Setter Property="Text">
                        <Setter.Value>
                            <Binding Path="SIMULATOR_CONTROL_BLADE_DATA.CONTROL_BLADE_ASSEMBLY.REACTOR_CORE_COORDINATE.RCC_MODEL_Y"></Binding>
                        </Setter.Value>
                    </Setter>
                </DataTrigger>
            </Style.Triggers>
        </Style>
</TextBlock.Style>

此绑定已损坏:

Binding="{Binding radSimulator, Path=IsChecked}"

这意味着您设置了两次路径,因为输入的没有任何属性名称的字符串将用作路径(请参阅 Binding),这可能是这样吗?

Binding="{Binding ElementName=radSimulator, Path=IsChecked}"

If you set the text locally the trigger will not be able to change the value due to precedence.

Move the default text into the style:

<!-- There are still issues with this -->
<TextBlock Grid.Row="2" Grid.Column="1">
    <TextBlock.Style>
        <Style TargetType="{x:Type TextBlock}">
            <Setter Property="Text" Value="{Binding SIMULATOR_CONTROL_BLADE_DATA.CONTROL_BLADE_ASSEMBLY.REACTOR_CORE_COORDINATE.RCC_REACTOR_Y}"/>
            <Style.Triggers>
                <DataTrigger Binding="{Binding radSimulator, Path=IsChecked}" Value="True">
                    <Setter Property="Text">
                        <Setter.Value>
                            <Binding Path="SIMULATOR_CONTROL_BLADE_DATA.CONTROL_BLADE_ASSEMBLY.REACTOR_CORE_COORDINATE.RCC_MODEL_Y"></Binding>
                        </Setter.Value>
                    </Setter>
                </DataTrigger>
            </Style.Triggers>
        </Style>
</TextBlock.Style>

This binding is broken:

Binding="{Binding radSimulator, Path=IsChecked}"

This means you set the path twice because the string entered without any property-name will be used as path (see the respective constructor of Binding), should this possibly be this?

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