I have a user control with a datagrid inside. I want the caller to be able to do something like this:
<local:MyControl>
<local:MyControl.GridColumns>
<DataGridTextColumn Header="Id" />
</local:MyControl.GridColumns>
</local:MyControl>
I tried to do something like this in my usercontrol definition:
<UserControl ...>
<DataGrid Colum开发者_JAVA百科ns={Binding GridColumns} />
</UserControl>
I have a GridColumns property in the user control. It does not work.
How to do this correctly?
Thanks.
You cannot bind that property as it is not a dependency property, so just forward it:
<DataGrid Name="datagrid" />
public ObservableCollection<DataGridColumn> Columns
{
get { return datagrid.Columns; }
}
精彩评论