I would like to create a hyperlink-column in wpf but rather with a command-binding instead of an uri.
<DataGridTemplateColumn Header="{lex:Loc newmaterialnumber}" Width="*">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock TextDecorations="Underline" Text="{Binding NewMaterialnumber}" Cursor="Hand" VerticalAlignment="Center" HorizontalAlignment="Left">
<TextBlock.InputBindings>
<MouseBinding MouseAction="LeftClick" Command="{Binding DataContext.OpenNewMaterialnumberCommand, RelativeSource={RelativeSource AncestorType={x:Type local:ArticleInfoSearchWindow}}}" />
</TextBlock.InputBindings>
</TextBlock>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
This works great but I have to select the row first before I can click the link. It would be achievable with a datatrigger which sets the row to selected on hover, but I don't really want do select the row on hover.
Any better ideas?
I came up with this solution. First of all create a new DataGridCommandColumn inherited by
DataGridBoundColumn.Then create a proxy:
Later you can use it: