Silverlight 条件复选框/单选按钮

发布于 2024-09-10 20:02:25 字数 218 浏览 4 评论 0原文

想象一下,我有一个名称列表,每个名称都与一个值配对(“C”代表复选框,“R”代表单选按钮)。

我可以组合一个模板来根据给定值显示正确的控件吗?

例如,如果我有“Name0,C”,我想显示一个标记为 Name0 的复选框。 如果我有“Name1,R”,我想显示一个标记为 Name1 的单选按钮。

有什么想法吗?或者仅使用模板就可以做到这一点?也许我需要在代码隐藏中做出决定?

Imagine I had a list of names, each paired with a value ("C" for CheckBox or "R" for RadioButton).

Can I put together a template to display the correct control based on the given value?

For instance if I have "Name0, C" I'd like to display a CheckBox labeled Name0.
If I have "Name1, R" I'd like to display a RadioButton labeled Name1.

Any ideas? Or is this even possible using only a template? Perhaps I would need to make the determination in the code-behind?

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

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

发布评论

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

评论(1

神经暖 2024-09-17 20:02:27

也许您可以使用同时具有复选框和单选按钮的数据模板。然后,您可以为 ValueToVisability 创建一个类型转换器来显示一个并隐藏另一个。

Perhaps you could use a data template that has both a Checkbox and RadioButton. You could then create a type converter for ValueToVisability to display one and hide the other.

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