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

Mouse cursor shape over columns

10 Answers 73 Views
GridView
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 26 Jul 2010, 07:49 PM
Hi,

Some of my columns are clickable (by capturing the MouseDownOnGridView event) and I'd like to change the mouse cursor to Cursors.Hand for these columns. What's the best way of doing this?

Thanks for your help, James.

10 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 27 Jul 2010, 07:54 AM
Hello James,

I would like to suggest you to create a named style with TargetType and apply that style to the desired columns.
<Style x:Key="Style1" TargetType="{x:Type telerik:GridViewHeaderCell}">
<Setter Property="Cursor" Value="Hand"/>
</Style>
Please try this and let me know if it works in your case.

Kind regards,
Vanya Pavlova
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
James
Top achievements
Rank 1
answered on 27 Jul 2010, 03:26 PM
Hi Vanya,

Thanks for your answer. I'm probably doing something obviously wrong, but can't get this working. I get the error message:

My code looks like:

<Style x:Name="HandStyle" TargetType="grid:GridViewCell">
            <Setter Property="Cursor" Value="Hand"/>
</Style>

And the columns:
<telerikGridView:GridViewDataColumn Header="Allocated" DataMemberBinding="{Binding TotalAllocation}" CellStyle="HandStyle" IsFilterable="False" Width="60" IsReadOnly="True" TextAlignment="Right"></telerikGridView:GridViewDataColumn>

Can you spot something obviously wrong?

Thanks for your help, James.
0
Vanya Pavlova
Telerik team
answered on 27 Jul 2010, 04:46 PM
Hi James,

You have defined a CellStyle in GridViewDataColumn,you should define HeaderCellStyle:
HeaderCellStyle={StaticResource HandStyle}

Regards,
Vanya Pavlova
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
James
Top achievements
Rank 1
answered on 27 Jul 2010, 08:22 PM
Hi Vanya,

Do I want a header style? I need the hand to appear over the clickable cells and not the header.

Thanks for your help, James.
0
Vlad
Telerik team
answered on 28 Jul 2010, 06:48 AM
Hello,

 Indeed if you need this for data cells you should use CellStyle however you need the right syntax for referring static resources. 

Kind regards,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
James
Top achievements
Rank 1
answered on 28 Jul 2010, 09:31 AM
Hi,

Sorry - I'm probably missing some obvious syntax here, but I'm just getting the error: Element is already the child of another element. [Line: 0 Position: 0] for this:

<UserControl x:Class="Myclass..."
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:telerikGridView="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
    >
    <UserControl.Resources>
       
        <Style x:Key="StyleHand" TargetType="{x:Type telerikGridView:GridViewCell}">
            <Setter Property="Cursor" Value="Hand"/>
        </Style>

    </UserControl.Resources>
    <Grid x:Name="LayoutRoot"...

The 'x:Type' is underlined with: "The type 'x:Type' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built."

Thanks for your help, James.
0
Vanya Pavlova
Telerik team
answered on 28 Jul 2010, 03:22 PM
Hello James,

Remove the x:Type from TargetType property and specify the style in this way:
<UserControl.Resources>
          
        <Style x:Key="StyleHand" TargetType="telerikGridView:GridViewCell">
            <Setter Property="Cursor" Value="Hand"/>
        </Style>
  
    </UserControl.Resources>
I am sorry for misleading you, I forgot that we cannot specify x:Type in a Style in SIlverlight as we can do in WPF.

Sincerely yours,
Vanya Pavlova
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
James
Top achievements
Rank 1
answered on 28 Jul 2010, 06:26 PM
Hi Vanya,

Thanks for your quick answer. I'm afraid I just went around in circles getting this error: Element is already the child of another element. So I'm just doing it with mouseover events. Would be good to know how to do it properly with styles though!

Thanks, James.
0
Accepted
Vanya Pavlova
Telerik team
answered on 29 Jul 2010, 08:15 AM
Hello James,

Attached is a sample project which demonstrates the desired behavior.

Please let me know if I can be of further assistance.

Kind regards,
Vanya Pavlova
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
James
Top achievements
Rank 1
answered on 29 Jul 2010, 09:18 AM
Brilliant - thanks very much!

The line I was missing was this: xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"

I've now put it into my App.xaml Application.resources and am using it throughout the app.

Thanks for your help, James.
Tags
GridView
Asked by
James
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
James
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or