查找控件(例如标签)并在运行时分配其内容 mvvm wpf

发布于 2024-09-10 03:03:56 字数 166 浏览 2 评论 0原文

我们的 Skins 文件夹中有一个 xaml 文件,设计师在其中为标签、单选按钮或复选框开发了一些样式。我需要在这个xaml文件中找到控件Label,并在运行时在virewModel中分配content属性,以便它可以根据数据库中的记录自动显示内容。如何实现这一目标。

请建议?

谢谢。

We have one xaml file in our Skins folder where designer has developed some styles for the labels,radiobuttons or checkboxes. I need to find the control, Label in this xaml file and assign the content property at runtime in virewModel so that it can automatically displays the content as per the records in the database. How to achieve this.

Kindly Suggest?

Thanks.

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

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

发布评论

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

评论(1

三生殊途 2024-09-17 03:03:56

为什么不直接将 LabelContent 属性绑定到您的视图模型:

<Label Content="{Binding CustomerName}"/>

Why not just have the Label's Content property bound to your view model:

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