Style property on GridViewDataColumn

6 posts, 0 answers
  1. Patrick
    Patrick avatar
    372 posts
    Member since:
    Aug 2012

    Posted 11 May 2015 Link to this post

    Hello,

    in the GridViewDataColumn control for WPF, there is a Style property. This property is not available in the Silverlight control. Is there a reason for that?

    This makes creating UI common to both Silverlight and WPF difficult (I can't use styles).

  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 11 May 2015 Link to this post

    Hello,

    In WPF, GridViewColumn inherits from FrameworkContentElement while in Silverlight it inherits from DependencyObject. That is where the difference comes from.

    Would you please share some more information on what result would you like to achieve?

    Regards,
    Dimitrina
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  3. DevCraft banner
  4. Patrick
    Patrick avatar
    372 posts
    Member since:
    Aug 2012

    Posted 11 May 2015 in reply to Dimitrina Link to this post

    Hi Dimitrina,

    I have a GridView with 30 columns, of which 28 have the same values for 5 properties. Using a style in WPF let me simplify the XAML code and also simplify the change in the formatting.

    The WPF style is defined as:

    <Style x:Key="ValueColumn" TargetType="tk:GridViewColumn">
      <Setter Property="HeaderTextAlignment" Value="Center" />
      <Setter Property="IsGroupable"         Value="False" />
      <Setter Property="TextAlignment"       Value="Center" />
      <Setter Property="Width"               Value="35" />
    </Style>
     
    <Style x:Key="BoldValueColumn" TargetType="tk:GridViewColumn" BasedOn="{StaticResource ValueColumn}">
      <Setter Property="Background" Value="#40D0D0D0" />
    </Style>

    Unfortunately, doing so will break the Silverlight compatibility: the same source code is used for both Silverlight and WPF clients.

  5. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 14 May 2015 Link to this post

    Hello,

    You can apply CellStyle instead. This is the recommended way.
    In case you may need to apply conditional styling, you can consider applying a CellStyleSelector

    Regards,
    Dimitrina
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  6. Patrick
    Patrick avatar
    372 posts
    Member since:
    Aug 2012

    Posted 14 May 2015 in reply to Dimitrina Link to this post

    Hi Dimitrina,

    It could be a possibility, except that HeaderTextAlignment, IsGroupable and Width properties are not accessible with CellStyle, making it about useless in my case..

  7. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 14 May 2015 Link to this post

    Hello Patrick,

    It is indeed not possible to set those properties through CellStyle, still, there is not another option to suggest as it comes to columns specifically. In case you would like to disable grouping at RadGridView's level, you may configure it with ShowGroupPanel="False".

    We apologize for this inconvenience.

    Regards,
    Dimitrina
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
Back to Top
DevCraft banner