Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to bind a property of a class which is in another assembly in WPF?

Tags:

binding

wpf

In WPF, is it possible to bind a property of class which is other assembly to the control which is in different assembly .Please help. Thanks

like image 343
Ershad Avatar asked Dec 17 '25 15:12

Ershad


1 Answers

Yea, you can reference that assembly to your wpf project, than add a namespace in xaml like this

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

than add that class to UserControl's resources

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

than bind to it's property

 <TextBox Text={Binding Source={StaticResource myClass},Path=MyProperty}/>
like image 136
Arsen Mkrtchyan Avatar answered Dec 19 '25 05:12

Arsen Mkrtchyan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!