Not sure what exactly you want to accomplish. In my WPF applications I always have my data defined in classes as follows:
public class Mydata:INotifyPropertyChanged
{
private string userName;
public string UserName
{
get { return userName; }
set
{
if ( userName != value )
{
userName = value;
OnPropertyChanged(()=>this.UserName);
}
}
}
public void OnPropertyChange ( string propertyName )
{
if ( PropertyChanged != null )
PropertyChanged( this, new PropertyChangedEventArgs( propertyName ) );
}
public void OnPropertyChange<t> ( Expression<func><t>> propertyExpression )
{
OnPropertyChange( propertyExpression.Name );
}
public event PropertyChangedEventHandler PropertyChanged;
}
</t></func></t>
Next in my codeBehind I have population code to expose this object as a public property:
....
public Mydata SomeData = new SomeData();
public MyUserControl()
{
Populate(SomeData);
}
...
Finally in my binding :
<my:myusercontrol horizontalalignment="Left" name="myUserControl" verticalalignment="Top" width="74" text="{Binding Path=SomeData.UserName, Mode=TwoWay}" xmlns:my="#unknown" />
In WPF all bound properties MUST implement INotifyPropertyChanged and all collections must be encapsulated in ObservableCollection's.