Binding ColumnDefinitions in Silverlight

2019-08-22 23:55发布

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?

1条回答
神经病院院长
2楼-- · 2019-08-23 00:40

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) });
        }
查看更多
登录 后发表回答