Click here to Skip to main content
15,887,273 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi
I am developing one wpf application in mvvm model in prism framework.i created one usercontrol in one module and i used in another module.i successfully import that usercontrol in my module but i can't bind properties to that user control. it act as a single control not different control in user control.so what i will do .following is my code

my usercontrol contain
3 radio button
3 text box
1 data grid

then i reference this usercontrol to my project:
XML
xmlns:l="clr-namespace:MagicHospital.Controls;assembly=MagicHospital.Controls"
       <l:PatientDetailsUserControl></l:PatientDetailsUserControl>

then how can i bind properties to controls in usercontrol.
Posted
Updated 19-Oct-12 23:48pm
v2

1 solution

If you want to use Binding you need to expose the usercontrol(s) as a DependencyProperty - Can access proprty in XAML or code behind.
AS an example you can expose the radiobutton as

C#
public static readonly DependencyProperty Radio1Property = DependencyProperty.Register("Radio1", typeof(RadioButton),
typeof(YourUserContol),
new PropertyMetadata());

        public RadioButton Radio1
        {
            get { return (RadioButton)this.GetValue(Radio1Property); }
            set { this.SetValue(Radio1Property, value); }
        }




or you can expose the controls as CLR-Public properties and you can then access in your code behind.

I hope this helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900