[转]silverlight Datagrid 行上增长ToolTip

有两种办法:

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

web

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>
相关文章
相关标签/搜索