Silverlight ItemsControl - 更改 ItemTemplate

发布于 2024-08-31 14:10:10 字数 150 浏览 1 评论 0原文

我有一个带有单选按钮列表的 ItemsControl - 在本例中,ItemTemplate 将包含一个绑定的单选按钮。 问题是,在某些情况下,我需要用复选框替换单选按钮,而不使用任何 C# 代码。这可能吗?我考虑使用 ValueConverter (C# 代码),但我不确定是否可行。

I have an ItemsControl with a list of radio buttons - in this case the ItemTemplate will contain a binded radio button.
The problem is that in some cases I need to replace the radio button with a check box without using any C# code. Is this possible? I thought at using a ValueConverter (C# code) but I don't know for sure if will work.

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

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

发布评论

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

评论(1

回眸一遍 2024-09-07 14:10:10

您可以在模板中放置一个单选按钮和一个复选框,然后在“Visible”属性中使用绑定表达式,以确保根据绑定的源对象只有其中一个可见。如果决定可见性的逻辑比源对象上的布尔值更复杂,请在绑定表达式中使用值转换器。

You could put both a radio button and a checkbox in the template, then use a binding expression in the "Visible" property that ensures only one of them is visible based on the source object being bound. If your logic to decide visibility is more complex than just a boolean on the source object, use a valueconverter in the binding expression.

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