Ershad
Ershad

Reputation: 957

how to bind a property of a class which is in another assembly in 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

Upvotes: 3

Views: 4986

Answers (1)

Arsen Mkrtchyan
Arsen Mkrtchyan

Reputation: 50752

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}/>

Upvotes: 10

Related Questions