Binding ColumnDefinitions in Silverlight
I have two separate 开发者_开发技巧Silverlight usercontrols containing grids and i want these to share a set of columndefinitions. The columndefinitions must be created dynamically. How can i do this?
You can just add them in code if that is sufficient:
private void CreateColumnDefinitions(Grid grid)
{
grid.ColumnDefinitions.Add(
new ColumnDefinition() { Width = new GridLength(10, GridUnitType.Star) });
grid.ColumnDefinitions.Add(
new ColumnDefinition() { Width = new GridLength(5, GridUnitType.Star) });
grid.ColumnDefinitions.Add(
new ColumnDefinition() { Width = new GridLength(5, GridUnitType.Star) });
}
精彩评论