这应该很简单,但我被困住了!如何在代码中创建以下多重绑定并将其应用于给定的行定义:
DbContext
谢谢!
答案 0 :(得分:0)
你去了:
//Create binding
var binding = new MultiBinding
{
Converter = new MyMultiConverter()
};
binding.Bindings.Add(new Binding("x") { ElementName = "obj1" });
binding.Bindings.Add(new Binding("y") { ElementName = "obj2" });
//create RowDefinition
var definition = new RowDefinition();
//set binding on HeightProperty
definition.SetBinding(RowDefinition.HeightProperty, binding);
//'myGrid' is the name of the grid instance
//add RowDefinition to grid
myGrid.RowDefinitions.Add(definition);
为了能够在代码隐藏中处理网格,您需要为网格添加名称:
<Grid Name="myGrid">
...
</Grid>