gpt4 book ai didi

wpf - 如何绑定(bind) WPF 中另一个程序集中的类的属性?

转载 作者:行者123 更新时间:2023-12-03 23:32:54 29 4
gpt4 key购买 nike

在 WPF 中,是否可以将其他程序集的类的属性绑定(bind)到不同程序集的控件。请帮助。谢谢

最佳答案

是的,您可以将该程序集引用到您的 wpf 项目,而不是像这样在 xaml 中添加命名空间

<UserControl xmlns:custom="clr-namespace:SampleClass;assembly=SampleLibrary"...

然后将该类添加到 UserControl 的资源中

<UserControl.Resources>
<custom:SampleClass x:Key="myClass"/>
</UserControl.Resources>

比绑定(bind)到它的属性

 <TextBox Text={Binding Source={StaticResource myClass},Path=MyProperty}/>

关于wpf - 如何绑定(bind) WPF 中另一个程序集中的类的属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1552839/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com