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

Get Style Height property value

1 Answer 49 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Fabiana asked on 12 Jul 2010, 06:57 PM
Hello support!

I created a new GridViewHeaderRow Style and use it in RadGridView. How to get , in page code, Height property of the the "CustomRadGridViewHeaderRow" style ? I need to know after Page_Loaded(), the GridViewHeaderRow Height .




<Style x:Key="CustomRadGridViewHeaderRow" TargetType="telerik:GridViewHeaderRow">





<Setter Property="Foreground" Value="Black" />





<Setter Property="FontSize" Value="11"></Setter>





<Setter Property="FontFamily" Value="Portable User Interface"></Setter>





<Setter Property="Background" Value="#E9D1D1D1" />





<Setter Property="BorderBrush" Value="White" />





<Setter Property="Height" Value="22" />





<Setter Property="MinHeight" Value="22" />



















<telerik:RadGridView HeaderRowStyle="{StaticResource CustomRadGridViewHeaderRow}" x:Name="RadgrdInbox">


















        <telerik:GridViewDataColumn x:Name="RadColumnInboxFrom" Width = "*" IsReadOnly="True" Header="From" CellTemplate="{StaticResource FromTemplate}"/>

















1 Answer, 1 is accepted

Sort by
Rossen Hristov
Telerik team
answered on 13 Jul 2010, 11:26 AM
Hi Fabiana,

Imagine that you have defined a Style in your page like this:

<UserControl x:Class="DataControlsTestApplication_SL.MainPage"
    d:DesignHeight="300" d:DesignWidth="400">
        <Style x:Key="MyStyle" TargetType="Button">
            <Setter Property="Height" Value="55"/>
    <Grid x:Name="LayoutRoot">
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        <StackPanel Orientation="Horizontal">
            <Button Name="withRadGridView" Content="With RadGridView" Click="withRadGridView_Click"/>
            <Button Name="unboundMode" Content="Unbound Mode" Click="unboundMode_Click"/>
            <Button Name="dds" Content="With DomainDataSource" Click="dds_Click"/>
        <sdk:Frame x:Name="ContentFrame" Grid.Row="1"/>

Then, if you write the following code in the code-behind of the page after the call to the InitializeComponent method, you will be able to get the height that you defined in XAML:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Telerik.Windows.Controls.Data.DataFilter;
using Telerik.Windows.Data;
using System.Diagnostics;
using System.Collections;
using Telerik.Windows.Controls;
using Telerik.SilverlightExtensions;
using System.ComponentModel.DataAnnotations;
namespace DataControlsTestApplication_SL
    public partial class MainPage : UserControl
        public MainPage()
            if (this.Resources.Contains("MyStyle"))
                Style myStyle = this.Resources["MyStyle"] as Style;
                if (myStyle != null)
                    Setter heightSetter = myStyle.Setters.OfType<Setter>()
                        .Where(setter => setter.Property == Button.HeightProperty)
                    if (heightSetter != null)
                        var height = heightSetter.Value;
        private void withRadGridView_Click(object sender, RoutedEventArgs e)
            this.ContentFrame.Source = new Uri("/WithRadGridView.xaml", UriKind.Relative);
        private void unboundMode_Click(object sender, RoutedEventArgs e)
            this.ContentFrame.Source = new Uri("/UnboundPage.xaml", UriKind.Relative);
        private void dds_Click(object sender, RoutedEventArgs e)
            this.ContentFrame.Source = new Uri("/WithDDSPage.xaml", UriKind.Relative);

The parts of the important code are in yellow. I hope this helps.

Kind regards,
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
Asked by
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Share this question