【发布时间】:2013-06-23 21:09:56
【问题描述】:
ListView GridView 中的绑定列
如何在 MouseDown 事件中获取 DataSource
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=Name, Mode=OneWay}"
MouseDown="NameCol_mousedown"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
这适用于另一个项目,在 ListView 中有一个按钮。
这是它尝试过的......
错误无法将“MS.Internal.NamedObject”类型的对象转换为“ListViewDragDrop.DocProp”类型。
DataSource 是 DocProp。
private void NameCol_mousedown(object sender, MouseButtonEventArgs e)
{
TextBlock tb = (TextBlock)sender;
object data = tb.DataContext;
dataSource = (DocProp)tb.DataContext;
}
【问题讨论】:
标签: c# .net wpf listview mouseevent