[英]Pass parameter to UserControl in XAML
我将Syncfusion的DockingManager
与MVVM适配器 DockingManager
使用,因此可以绑定实现IDockElement
的ViewModel列表。
我以这种方式使用它:
<dm:DockingAdapter Grid.Row="1" ItemsSource="{Binding DockingItems}" />
另外,我正在使用最新版本的Catel及其自定义控件 。
DockingManager
的MVVM适配器需要这些条目,才能从ViewModel创建视图:
<DataTemplate DataType="{x:Type local:EventEditorViewModel}">
<Grid>
<events:EventEditorControl/>
</Grid>
</DataTemplate>
问题是,我的EventEditorControl
的构造函数中有一个需要ViewModel的参数。
如何传递正确的ViewModel?
您不能使用xaml将参数传递给构造函数。
让您将参数设为依赖项属性:
<events:EventEditorControl MyParameterAsDependencyProperty="{Binding SomeProperty}" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.