开发者

wpf datagrid on click event

I use datagrid table 开发者_StackOverflow社区on my project. One of the column of the datagrid is the path of the document according to my project. I would like to do that:

When the user clicks the path cell/hyperlink cell,

  • Program will get the path,
  • Program will open another tab.

I couldn't see the onclick event for the column, how can i do this? And also how can I switch the tabitems on the same wpf Window?

Hyper link column is that:

<toolkit:DataGridHyperlinkColumn Header="Path" Binding="{Binding path}" IsReadOnly="True" TargetName="{Binding Path=path}">
</toolkit:DataGridHyperlinkColumn >


Have you tried using Triggers?

you could define a trigger for the MouseClick event and there set the other tab focus


You can try using a DataGridTemplateColumn into which you place a Textblock and Hyperlink. This will provide a Click event. Here is a sample for defining a hyperlink column:

<dg:DataGridTemplateColumn Header="Link Column" Width="125">
    <dg:DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
            <TextBlock Margin="0,0,0,0">
                <Hyperlink Tag="{Binding TargetUrl}" Click="Url_Click">
                    <InlineUIContainer>
                        <TextBlock Text="{Binding TargetText}"/>
                    </InlineUIContainer>
                </Hyperlink>
            </TextBlock>
        </DataTemplate>
    </dg:DataGridTemplateColumn.CellTemplate>
</dg:DataGridTemplateColumn> 

Note that this was from a project using .Net 3.5 and WPF Toolkit. dg is defined in the XAML with xmlns:dg="http://schemas.microsoft.com/wpf/2008/toolkit"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜