This is a migrated thread and some comments may be shown as answers.

How to Style Hyperlinks in the RadGridView

5 Answers 225 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Bob asked on 20 Sep 2011, 03:30 PM
I was wondering how to style the Hyperlinks that are created within a RadGridView. Do you have a code sample?
Thanks,
Strasz

5 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 20 Sep 2011, 03:37 PM
Hi Bob,

 

Both GridViewHyperlinkColumn/GridViewDynamicHyperlinkColumn use a plain HyperlinkButton. If you define a simple style targeted at HyperlinkButton it will be handled correspondingly by these columns:


<Style TargetType="HyperlinkButton">
    <Setter Property="Foreground" Value="Red"/>
...
</Style>


Hope this helps! 


Kind regards,
Vanya Pavlova
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
answered on 20 Sep 2011, 03:44 PM
it does NOT recognize the HyperlinkButton as a valid TargetType
0
Vanya Pavlova
Telerik team
answered on 20 Sep 2011, 03:53 PM
Hi Bob,

 
I have pasted the Silverlight version of the style by mistake, sorry for that! In WPF you may create a style targeted at a Hyperlink instead of HyperlinkButton:

<Style TargetType="{x:Type Hyperlink}">
        <Setter Property="Foreground" Value="Red"/>
    </Style>
    </Window.Resources>
    <Grid x:Name="LayoutRoot" DataContext="{Binding Source={StaticResource SampleDataSource}}">
        <telerik:RadGridView VerticalAlignment="Top" ItemsSource="{Binding Collection}">
            <telerik:RadGridView.Columns>
                <telerik:GridViewHyperlinkColumn DataMemberBinding="{Binding Property1}"/>
                </telerik:RadGridView.Columns>
            </telerik:RadGridView>
    </Grid>



Best wishes,
Vanya Pavlova
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
answered on 22 Sep 2011, 08:00 PM
The new version you pasted does not work either
<Style TargetType="{x:Type Hyperlink}">
        <Setter Property="Foreground" Value="Red"/>
    </Style>
    </Window.Resources>
    <Grid x:Name="LayoutRoot" DataContext="{Binding Source={StaticResource SampleDataSource}}">
        <telerik:RadGridView VerticalAlignment="Top" ItemsSource="{Binding Collection}">
            <telerik:RadGridView.Columns>
                <telerik:GridViewHyperlinkColumn DataMemberBinding="{Binding Property1}"/>
                </telerik:RadGridView.Columns>
            </telerik:RadGridView>
    </Grid>
You have </Window.Resources> but you never have an opening tag...also you have binding to Property1 which makes no sense to me.
Can you send some code that functions properly? Thanks
Strasz
0
Vanya Pavlova
Telerik team
answered on 23 Sep 2011, 08:01 AM
Hello Bob,

 

Yes, the style resides within the Window's ResourceCollection.
 I am attaching you sample application illustrating this approach. 



All the best,
Vanya Pavlova
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
GridView
Asked by
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Answers by
Vanya Pavlova
Telerik team
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Share this question
or