Bra*_*AGr 6 c# wpf xaml code-behind mvvm
我有一个用户控件中使用的Xaml,用作属性网格中的编辑器.问题是,从后面的代码中附加行为的c#会是什么样子?
<i:Interaction.Behaviors>
<igExt:XamComboEditorSelectedItemsBehavior SelectedItems="{Binding SelectedItems, ElementName=_uc}"/>
</i:Interaction.Behaviors>
Run Code Online (Sandbox Code Playgroud)
因为这是在一个动态加载到PropertyGrid中的编辑器上,所以我只是创建一个编辑器实例,其中包含来自代码的绑定,而不是必须拥有非常简短且只包含一个编辑器的不同xaml文件.
或者更简单地重新实现行为中的所有代码并在我在后面的代码中创建编辑器时调用它?
EvA*_*lex 20
XamComboEditorSelectedItemsBehavior behavior = new XamComboEditorSelectedItemsBehavior();
behavior.SetBinding(XamComboEditorSelectedItemsBehavior.SelectedItemsProperty, new Binding()
{
ElementName = "_uc",
Path = new PropertyPath("SelectedItems"),
Mode = BindingMode.TwoWay
});
Interaction.GetBehaviors(yourElementName).Add(behavior)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13962 次 |
| 最近记录: |