当鼠标悬停在某些单元格上时 DataGrid 弹出框
我有一个数据网格,其中有 5 列,名称如下
RowID, 姓名, 年龄, 高度, 图像
我想要做的是,当鼠标悬停在图像列中的单元格上时,如果那里有图像,我希望出现一个弹出框。我知道我可以只使用弹出窗口的工具提示,但检查的最佳方法是将鼠标悬停在单元格上,以及单元格是否存在图像,如果有,则显示弹出窗口。
编辑:- 添加了图像列的 DataGrid 列的代码
<DataGridTemplateColumn Header="Image">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Image Width="32" Height="32" HorizontalAlignment="Center" VerticalAlignment="Center"
Source="{Binding IMG, Converter={StaticResource ImageConvert}}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
I have a Datagrid with say 5 Columns named as follows
RowID,
Name,
Age,
Height,
Image
What I want to do is when the mouse is over a cell in the Image Column, if there is an image there I want a pop up box to appear. I know I can just use a tool tip for the pop up but what's the best way of doing the check of is mouse over cell and does cell have an image present, if so then display popup.
EDIT:- Added code for DataGrid Column for Image Column
<DataGridTemplateColumn Header="Image">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Image Width="32" Height="32" HorizontalAlignment="Center" VerticalAlignment="Center"
Source="{Binding IMG, Converter={StaticResource ImageConvert}}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用
IsMouseOver
属性来确定鼠标是否位于对象上方,并使用MultiDataTrigger
来评估多个条件。You can use the
IsMouseOver
property to determine if the mouse is over an object, and aMultiDataTrigger
to evaluate multiple conditions.有几种方法。我建议创建一个模板列类型/样式,并在鼠标位于单元格内时将其实现为触发器。
There are a couple of ways. What I would recommend is to create a Template column type / style and implement this as a trigger when the mouse is within the cell.