How to specify a ToolTip for a control in a Style from XAML?

后端 未结 6 1862
面向向阳花
面向向阳花 2021-02-13 09:44

I\'m using a the WPF datagrid from the Microsoft CodePlex project. I have a custom control that I want to databind to a field from the row of the datagrid. I can\'t for the life

6条回答
  •  半阙折子戏
    2021-02-13 10:33

    Not sure you can do it through XAML.

    A easier way might be to just handle the LoadingRow event. In xaml have something like:

    
    

    Then in code behind

    void dgResults_LoadingRow(object sender, DataGridRowEventArgs e)
    {
        DataGridRow row = e.Row;
        row.ToolTip = row.DataContext as string;
    }
    

    Obviously you will have to change the code depending on how you are populating the data in the datagrid. This is also untested =)

提交回复
热议问题