Suchai Tammewar
Suchai Tammewar

Reputation: 31

How to use the NavigateURL property for the GridViewHyperLinkColumn in wpf?

How to use the NavigateURL property for the GridViewHyperLinkColumn in wpf ?

Question : In my datagird i have a column which is of GridViewHyperLinkColumn and now when i click on the data of GridViewHyperLinkColumn in grid, then i have to get a pop up screen, which is of another xaml(Say SetPassword.xaml) file. so how to get a popup screen when i click in the GridViewHyperLinkColumn data in the datagrid ? and to which prpoerty i have to assign the URL, so that when i click in the GridViewHyperLinkColumn data a popup should be displayed ?

Thanks, Suchai

Upvotes: 0

Views: 872

Answers (1)

John Bowen
John Bowen

Reputation: 24453

I assume you mean DataGridHyperlinkColumn since there is no built in GridViewHyperLinkColumn. That column type is designed only for uri based navigation, which you could use if you had a WPF navigation application and wanted it to jump to a different page, for example. Since you want a completely different behavior of opening a new window you'll need to do that from code, which means using a different mechanism. Using a template column you can add in a Hyperlink that can have either a Click event handler or a bound Command (if using MVVM). Here's an example using Click:

<DataGridTemplateColumn IsReadOnly="True">
    <DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
            <TextBlock>
                <Hyperlink Click="Hyperlink_Click_1">
                    <TextBlock Text="{Binding Path=SomePropertyForThisColumn}"/>
                </Hyperlink>
            </TextBlock>
        </DataTemplate>
    </DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>

Upvotes: 1

Related Questions