[转]silverlight Datagrid 行上增加ToolTip

有两种办法:

1. 直接在后台处理
在数据绑定后 ,注册LoadingRow 事件
this.DataGrid.LoadingRow += new EventHandler<DataGridRowEventArgs>(DataGrid_LoadingRow);

void DataGrid_LoadingRow(object sender, DataGridRowEventArgs e)
{
      Task ts = e.Row.DataContext as Task;
      ToolTipService.SetToolTip(e.Row, ts.Name);
      //throw new NotImplementedException();
}

2. 稍微麻烦点, 重写datagrid row 模板, 
在微软msdn 上能找到 行模板,找到

<Storyboard>
<DoubleAnimation Storyboard.TargetName="BackgroundRectangle" Storyboard.TargetProperty="Opacity" Duration="0" To="0"/>
 </Storyboard>
在后面加上
<Storyboard> 
<DoubleAnimation Storyboard.TargetName="BackgroundRectangle" Storyboard.TargetProperty="Opacity" Duration="0" To="0" ToolTipService.ToolTip="{Binding Name}"/> 
 </Storyboard>
posted on 2013-08-16 16:29  SamWang  阅读(830)  评论(0编辑  收藏  举报