- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这是我要完成的示例:
<Window x:Class="CheckBoxBinding.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<StackPanel>
<CheckBox Name="myCheckBox">this</CheckBox>
<Grid>
<Grid.Resources>
<Style TargetType="ListBox">
<Style.Triggers>
<Trigger Property="{Binding ElementName=myCheckBox, Path=IsChecked}" Value="True">
<Setter Property="Background" Value="Red" />
</Trigger>
</Style.Triggers>
</Style>
</Grid.Resources>
<ListBox>
<ListBoxItem>item</ListBoxItem>
<ListBoxItem>another</ListBoxItem>
</ListBox>
</Grid>
</StackPanel>
</Window>
A 'Binding' cannot be set on the 'Property' property of type 'Trigger'. A 'Binding' can only be set on a DependencyProperty of a DependencyObject.
最佳答案
尝试使用 DataTrigger。将您的 Grid.Resources 替换为以下内容,它可以工作:
<Grid.Resources>
<Style TargetType="ListBox">
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=myCheckBox, Path=IsChecked}" Value="True">
<Setter Property="Background" Value="Red" />
</DataTrigger>
</Style.Triggers>
</Style>
</Grid.Resources>
关于wpf - 如何将另一个 DependencyProperty 绑定(bind)到 CheckBox 的 IsChecked 属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2915986/
我有一个选择“全部”复选框,我希望将其绑定(bind)到其他复选框的 (IsChecked || !IsEnabled)。 选中“全部”会选中所有启用的复选框。 取消选中“全部”会取消选中所有复选框。
我在运行时动态创建了一些复选框,现在我想知道其中一个是否被选中。我怎样才能做到这一点? for (int i = 0; i < cnt; i++) { cb =
当我在学习 Android 开发者基础类(class)时,我对下面的代码产生了以下疑问。 public void onRadioButtonClicked(View view) { /
是否弃用了 isChecked() 方法? 我正在为 android UI 编码并使用 UiAutomator Framework 那里没有显示这个方法 我正在尝试通过 isChecked() 验证一
这让我很生气。我有一个简单的 WPF 切换按钮,有两个 IsChecked 触发器。一个为真值,另一个为假值。未选中按钮时它工作正常,应用了我的 false 样式;但是,系统从不应用 IsChecke
如何使用单选按钮“IsChecked”属性控制文本框的可见性? 我有一个两个文本框,比如说 txtbox1 和 txtbox2,我想根据单选按钮 IsChecked 属性绑定(bind)这两个文本框的
所以我有一个复选框,它使用 WPF/MVVM 触发命令,这工作正常,但我想使用复选框的 IsChecked 属性作为命令参数。我试过这个。 但是我在输出窗口中收到一个错误,上面写着 System
我有两个单选按钮,我希望默认选择其中一个。我添加了 IsChecked="true" ,但它不起作用。我还尝试将其设置在窗口加载中。 但是当我单击第二个选项然后单击第一个选项时,一切正常。 它只是在第
我有以下用于切换按钮的 xaml:
我正在尝试构建一个函数来更改复选框选择上的文本,请检查以下内容... Jquery代码 $(document).ready(function() { if($('#active').is(':chec
我正在编写一个程序,其中有一个由一系列复选框组成的组合框。用户可以选择任意数量的复选框。之后,当他点击一个按钮时,我想检查所有复选框以查看哪些已被选中,哪些未被选中。 但我不知道该怎么做。我尝试了很多
这个问题在这里已经有了答案: How do I compare strings in Java? (23 个回答) 关闭 7 年前。 我在 Activity 上使用复选框来确定需要将对象添加到哪个列
选中复选框时,以下代码不起作用。无论复选框是否被选中,它都会跳转到“else”语句。 void MainWindow::runButtonClicked() {
我有一个使用 C# 编写的 UWP 应用程序。我有一个单选按钮,用户可以选中或取消选中。默认情况下它是选中的,用户可以在需要时取消选中它。但是,当他们取消选中它时,RadioButton.IsChec
这是我要实现的目标的简化示例; " id="myCheckBox" /> 然后在我后面的代码中; public partial class _Default : System.Web.UI.Page
找到了很多例子,但没有一个合适!我的列表框是 Result 对象的列表。可以在列表框中选中或取消选中结果以将其标记为“允许”传输。 文件列表模板
Android version: 3.1 API version: Android 2.2 Device: Motorola MX604 我动态创建了 CheckedTextView 项目的多选 Li
我正在尝试使用 fragment 构建我的 PreferenceActivity。我有一个包含两个 CheckBoxPreferences 的 PreferenceFragment: 我的 Fra
我正在努力测试类的属性值是否在单击切换器后发生变化。 所以这里我有组件类(没什么复杂的-.-): import { Component, EventEmitter, Input, OnInit, Ou
我有带有 ToggleButtons 数量的自定义控件: ...
我是一名优秀的程序员,十分优秀!