【发布时间】:2015-04-27 06:54:00
【问题描述】:
我有具有数据网格的用户控件。此用户控件已添加到 WPF 主窗口。我正在通过气泡事件处理网格选择更改事件。
<ListBox x:Name="myListBox" Grid.Row="0"
ItemsSource="{Binding Path=_myControl}"
ScrollViewer.VerticalScrollBarVisibility="Auto"
SelectedItem="{Binding CurrentItem}" SelectedIndex="1">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<local:UCSearchEntity GridRowSelectionConfirmed="{Binding Path=UCSearchEntity_GridRowSelectionConfirmed}" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
public class MyViewModel:INotifyPropertyChanged
{
}
错误是Provide value on 'System.Windows.Data.Binding' threw an exception.
如何在我的主窗口 viewModel 中访问这个用户控件事件?
【问题讨论】:
-
你不能对这样的事件进行绑定。
-
@PhilipStuyck 不违反 MVVM 吗?
-
啊,但这是一个完全不同的问题,是的,确实如此,但是您需要使用高级概念,例如行为。
标签: c# wpf user-controls attachedbehaviors