惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
T
Threatpost
Latest news
Latest news
N
News | PayPal Newsroom
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Help Net Security
Help Net Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
AI
AI
Simon Willison's Weblog
Simon Willison's Weblog
TaoSecurity Blog
TaoSecurity Blog
The Last Watchdog
The Last Watchdog
L
LINUX DO - 热门话题
Google DeepMind News
Google DeepMind News
T
Threat Research - Cisco Blogs
O
OpenAI News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
The Exploit Database - CXSecurity.com
NISL@THU
NISL@THU
Application and Cybersecurity Blog
Application and Cybersecurity Blog
S
Securelist
小众软件
小众软件
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Martin Fowler
Martin Fowler
S
SegmentFault 最新的问题
Cisco Talos Blog
Cisco Talos Blog
云风的 BLOG
云风的 BLOG
AWS News Blog
AWS News Blog
GbyAI
GbyAI
N
News and Events Feed by Topic
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
美团技术团队
Engineering at Meta
Engineering at Meta
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
S
Schneier on Security
博客园 - 聂微东
V2EX - 技术
V2EX - 技术
T
Troy Hunt's Blog
SecWiki News
SecWiki News
S
Secure Thoughts
B
Blog RSS Feed
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
腾讯CDC
H
Heimdal Security Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Apple Machine Learning Research
Apple Machine Learning Research
月光博客
月光博客
www.infosecurity-magazine.com
www.infosecurity-magazine.com
P
Privacy International News Feed

博客园 - Amanda2007

用户中心 - 博客园 用户中心 - 博客园 Silverlight不支持GIF或BMP文件格式 RotateTransform的CenterX和CenterY和元素的RenderTransformOrigin属性与 用户中心 - 博客园 用户中心 - 博客园 用户中心 - 博客园 用户中心 - 博客园 用户中心 - 博客园 用户中心 - 博客园 用户中心 - 博客园 用户中心 - 博客园 为什么silverlight的PasswordBox控件的password属性不可以绑定?该如何实现绑定? 用户中心 - 博客园 如何获取silverlight 应用程序的版本号。 如何自定义datagrid控件的某一行。 背景图片的自适应 在网页上设置容器的高度的百分比。 为canvas添加背景图片
鼠标进入离开DataGrid的行的操作。
Amanda2007 · 2008-10-21 · via 博客园 - Amanda2007

今天在论坛上看到一个人想实现这样的一个功能:

1. 在datagrid空间里有很多行很多列。

2. 其中的一列有两个空间: button和image

3. 默认情况下,显示Button,如果当鼠标Hover该行的时候,则显示图片,隐藏button;当鼠标离开的时候,就隐藏图片,显示button.

下面是datagrid的 xaml代码:

datagrid

如果有实现鼠标的操作,需要用到datagrid两个事件 :MouseEnter 、MouseLeave 。

这两个事件需要在datagrid的rowloading事件里面注册:

注册鼠标的事件

事件

然后根据鼠标的操作,使用VisualTreeHelper 找到datagrid的controlTemplate中的控件,然后显示或隐藏他们:

控件的显示/隐藏


          由于图片 和button控件的高度的差别,在从图片切换到Button的时候,发现datagrid的行变得比较高,没有自适应高度。所以需要在MouseEnter 、MouseLeave 事件中,手动的设置行高。