Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > GridView > EmptyDataTemplate RadGridView

Not answered EmptyDataTemplate RadGridView

Feed from this thread
  • Paloma avatar

    Posted on Apr 22, 2009 (permalink)

    Hi everybody!!!
    Does anybody know if there's an EmptyDataTemplate for the RadGridView for Silverlight?
    Thanks

    Reply

  • Pavel Pavlov Pavel Pavlov admin's avatar

    Posted on Apr 23, 2009 (permalink)

    Hi Paloma,

    Do you mean a template that is shown when no data is present for the RadGridView at all or a template for the cell when the value is null ?

    All the best,
    Pavel Pavlov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.

    Reply

  • Paloma avatar

    Posted on Apr 24, 2009 (permalink)

    Hi Pavel,
    I mean a template that is shown when no data is present for the RadGridView at all.
    Thanks

    Reply

  • Pavel Pavlov Pavel Pavlov admin's avatar

    Posted on Apr 28, 2009 (permalink)

    Hello Paloma,

    Unfortunately we are missing that feature. I have already talked to my team and we have decided to schedule this  for the Q2 release. Meanwhile I can recommend using external panel placed "over" the RadGridView with your custom content or text. Listening to the ItemsSource collection changes and switching visibility of that panel should do the work .
    Let me know if you need further  help. I can  prepare  a sample for you .

    Greetings,
    Pavel Pavlov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.

    Reply

  • Ravindranath Wickramanayake avatar

    Posted on Feb 16, 2010 (permalink)

    Could you please show sample code. thanks

    Reply

  • Vlad Vlad admin's avatar

    Posted on Feb 17, 2010 (permalink)

    Hi,

    You can check this post for more info:
    http://blogs.telerik.com/pavelpavlov/posts/10-02-01/empty_data_template_in_radgridview_for_silverlight_and_wpf.aspx

    Greetings,
    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.

    Reply

  • Milind Raje avatar

    Posted on Feb 4, 2011 (permalink)

    hi,
    Has this been added already? if so what is the template format?
    thanks
    milind

    Reply

  • Vlad Vlad admin's avatar

    Posted on Feb 7, 2011 (permalink)

    Hi,

    This is still not part of the grid - you can use the example from the blog post to achieve your goal. 

    Best wishes,
    Vlad
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>

    Reply

  • Dean Wyant avatar

    Posted on May 11, 2011 (permalink)

    Here you go - an EmptyDataTemplate Attached property.  (The blog posts a behavior)

    I needed to set the template from code behind and I thought it would be great to have it be an Attached Property.
    As discussed in http://www.telerik.com/help/silverlight/radtabcontrol-item-templates-and-selectors.html and other topics, a DataTemplate property can be set in code, from a Resource and using Style / Setter.

    I added a default template so you can just set EmptyText="Your Text." if you do not need your own template.

    To access the properties in your xaml, do not forget to add the reference - something like this
        xmlns:gvp="clr-namespace:Telerik.Windows.Controls.GridView;assembly=MyAssembly"
    
    Then you can do this:
        <telerik:RadGridView ... gvp:RadGridViewProperties.EmptyText="No Matching Data."...
    Or you can make your own template in a resource like so:

      <telerik:RadGridView ... gvp:RadGridViewProperties.EmptyDataTemplate="{StaticResource MyEmptyDataTemplate}">
    
      
    <UserControl.Resources>     <DataTemplate x:Key="MyEmptyDataTemplate" >       <TextBlock Text="Custom Empty Data Template" HorizontalAlignment="Center"  VerticalAlignment="Center" />     </DataTemplate>      </UserControl.Resources>

    I have not tried to set it in a Style, but I believe the syntax would be:

           <Style TargetType="telerik:RadGridView">
               
    <Setter Property="gvp:RadGridViewProperties.EmptyDataTemplate">
                   
    <Setter.Value>
                      <DataTemplate>
                          <TextBlock Text="Custom Empty Data Template" HorizontalAlignment="Center"  VerticalAlignment="Center" />
                      </DataTemplate>   
                   </Setter.Value>
               
    </Setter>
           
    </Style>

    In code behind:
    RadGridViewProperties.SetEmptyText(grid, "No Matching Data.");
    RadGridViewProperties.SetEmptyDataTemplate(grid, MyEmptyDataTemplate);
    

    RadGridViewProperties.cs

    using System;
    using System.Linq;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Markup;
    using System.Collections;
    using Telerik.Windows.Data;
      
    namespace Telerik.Windows.Controls.GridView
    {
      public class RadGridViewProperties
      {
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        #region EmptyDataTemplateHandler
      
        internal class EmptyDataTemplateHandler
        {
          private RadGridView _grid;
          private ContentPresenter _contentPresenter;
      
          internal EmptyDataTemplateHandler(RadGridView grid)
          {
            _grid = grid;
            Grid rootGrid = _grid.ChildrenOfType<Grid>().FirstOrDefault();
            if (rootGrid != null)
            {
              LoadContentPresenter(rootGrid);
              _grid.Items.CollectionChanged -= OnGridCollectionChanged;
              _grid.Items.CollectionChanged += OnGridCollectionChanged;
              SetVisibility();
            }
          }
      
          internal void Unhook()
          {
            _grid.Items.CollectionChanged -= OnGridCollectionChanged;
          }
      
          private void OnGridCollectionChanged(object sender, 
            System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
          {
            SetVisibility();
          }
      
          private void LoadContentPresenter(Grid rootGrid)
          {
            _contentPresenter = new ContentPresenter();
            _contentPresenter.IsHitTestVisible = false;
            _contentPresenter.SetValue(Grid.RowProperty, 2);
            _contentPresenter.SetValue(Grid.RowSpanProperty, 2);
            _contentPresenter.SetValue(Grid.ColumnSpanProperty, 2);
            _contentPresenter.SetValue(Border.MarginProperty, new Thickness(0, 27, 0, 0));
              rootGrid.Children.Add(_contentPresenter);
          }
      
          private void SetVisibility()
          {
            if (_grid != null)
            {
              if (_contentPresenter != null)
              {
                if (_grid.Items.Count == 0)
                {
                  LoadEmptyDataTemplate(); // Always load because it may be changed at any time
                  _contentPresenter.Visibility = Visibility.Visible;
                }
                else
                  _contentPresenter.Visibility = Visibility.Collapsed;
              }
            }
          }
      
          private void LoadEmptyDataTemplate()
          {
            var template = GetEmptyDataTemplate(_grid);
            if (template == null)
              template = GetDefaultTemplate();
            _contentPresenter.ContentTemplate = template;
          }
      
          private DataTemplate GetDefaultTemplate()
          {
            string text = GetEmptyText(_grid);
            if (String.IsNullOrEmpty(text))
              text = "No Matching Records Found.";
      
            var template = XamlReader.Load(String.Format(
    xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">
       <TextBlock Text=""{0}"" HorizontalAlignment=""Center""  VerticalAlignment=""Center"" />
    </DataTemplate>", text));
            return (DataTemplate)template;
          }
        }
        #endregion EmptyDataTemplateHandler
        //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 
      
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        #region EmptyDataTemplate and EmptyText
      
        /// <summary>
        /// The template to use when there is no data to display in the grid
        /// When not set and EmptyText is set, a default template is used
        /// </summary>
        /// <see cref="EmptyTextProperty"/>
        public static readonly DependencyProperty EmptyDataTemplateProperty =
          DependencyProperty.RegisterAttached("EmptyDataTemplate", typeof(DataTemplate), 
          typeof(RadGridView), new PropertyMetadata(OnEmptyDataTemplateChanged));
      
        #region Accessors
        /// <summary>
        /// The template to use when there is no data to display in the grid
        /// When not set and EmptyText is set, a default template is used
        /// </summary>
        /// <see cref="EmptyTextProperty"/>
        public static DataTemplate GetEmptyDataTemplate(DependencyObject obj)
        {
          return (DataTemplate)obj.GetValue(EmptyDataTemplateProperty);
        }
      
        /// <summary>
        /// The template to use when there is no data to display in the grid
        /// When not set and EmptyText is set, a default template is used
        /// </summary>
        /// <see cref="EmptyTextProperty"/>
        public static void SetEmptyDataTemplate(DependencyObject obj, DataTemplate value)
        {
          obj.SetValue(EmptyDataTemplateProperty, value);
        }
        #endregion Accessors
      
        /// <summary>
        /// The text to show when using the default EmptyDataTemplate.
        /// Default text = "No Matching Records Found."
        /// If EmptyDataTemplate is set, EmptyText is not used.
        /// <see cref="EmptyDataTemplateProperty"/>
        /// </summary>
        public static readonly DependencyProperty EmptyTextProperty =
          DependencyProperty.RegisterAttached("EmptyText", typeof(string), 
          typeof(RadGridView), new PropertyMetadata(OnEmptyTextChanged));
      
        #region Accessors
        /// <summary>
        /// The text to show when using the default EmptyDataTemplate.
        /// Default text = "No Matching Records Found."
        /// If EmptyDataTemplate is set, EmptyText is not used.
        /// <see cref="EmptyDataTemplateProperty"/>
        /// </summary>
        public static string GetEmptyText(DependencyObject obj)
        {
          return (string)obj.GetValue(EmptyTextProperty);
        }
      
        /// <summary>
        /// The text to show when using the default EmptyDataTemplate.
        /// Default text = "No Matching Records Found."
        /// If EmptyDataTemplate is set, EmptyText is not used.
        /// <see cref="EmptyDataTemplateProperty"/>
        /// </summary>
        public static void SetEmptyText(DependencyObject obj, string value)
        {
          obj.SetValue(EmptyTextProperty, value);
        }
        #endregion Accessors
      
        #region EventHandlers
        private static void OnEmptyDataTemplateChanged(DependencyObject d, 
          DependencyPropertyChangedEventArgs e)
        {
          var grid = d as RadGridView;
          if (grid != null)
          {
            if (e.NewValue == null)
              UnhookEmptyDataTemplate(grid);
            else
              HookEmptyDataTemplate(grid);
          }
        }
      
        private static void OnEmptyTextChanged(DependencyObject d, 
          DependencyPropertyChangedEventArgs e)
        
          var grid = d as RadGridView;
          if (grid != null)
          {
            if (String.IsNullOrEmpty((String)e.NewValue))
              UnhookEmptyDataTemplate(grid);
            else
              HookEmptyDataTemplate(grid);
          }
        }
      
        private static void OnEmptyDataTemplateGridLoaded(object sender, EventArgs e)
        {
          if (InitEmptyDataTemplate(sender))
            ((RadGridView)sender).Loaded -= OnEmptyDataTemplateGridLoaded;
        }
      
        private static void OnEmptyDataTemplateGridDataLoaded(object sender, EventArgs e)
        {
          if (InitEmptyDataTemplate(sender))
            ((RadGridView)sender).DataLoaded -= OnEmptyDataTemplateGridDataLoaded;
        }
      
        #endregion EventHandlers
      
        #region Implementation
        /// <summary>
        /// The ContentPresenter to used to hold the EmptyDataTemplate
        /// This is used internally to store/retrieve the ContentPresenter
        /// </summary>
        internal static readonly DependencyProperty EmptyDataTemplateHandlerProperty =
          DependencyProperty.RegisterAttached("EmptyDataTemplateHandler"
          typeof(EmptyDataTemplateHandler), typeof(RadGridView), null);
      
        #region Accessors
        internal static EmptyDataTemplateHandler GetEmptyDataTemplateHandler(DependencyObject obj)
        {
          return (EmptyDataTemplateHandler)obj.GetValue(EmptyDataTemplateHandlerProperty);
        }
      
        internal static void SetEmptyDataTemplateHandler(DependencyObject obj, 
          EmptyDataTemplateHandler value)
        {
          EmptyDataTemplateHandler handler = GetEmptyDataTemplateHandler(obj);
          if (handler != null)
            handler.Unhook();
          obj.SetValue(EmptyDataTemplateHandlerProperty, value);
        }
        #endregion Accessors
      
        private static bool InitEmptyDataTemplate(object sender)
        {
          var grid = sender as RadGridView;
          if (grid != null)
          {
            EmptyDataTemplateHandler handler = new EmptyDataTemplateHandler(grid);
            return true;
          }
          return false;
        }
      
      
        private static void HookEmptyDataTemplate(RadGridView grid)
        { // Attach to Loaded, which will attach to CollectionChanged
          UnhookEmptyDataTemplate(grid); // It does not hurt to unhook before hooking
          grid.Loaded += OnEmptyDataTemplateGridLoaded;
          grid.DataLoaded += OnEmptyDataTemplateGridDataLoaded;
        }
      
        private static void UnhookEmptyDataTemplate(RadGridView grid)
        { // Make sure events are no longer attached
          grid.Loaded -= OnEmptyDataTemplateGridLoaded;
          grid.DataLoaded -= OnEmptyDataTemplateGridDataLoaded;
          SetEmptyDataTemplateHandler(grid, null);
        }
      
        #endregion Implementation
      
        #endregion EmptyDataTemplate and EmptyDataText
        //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 
      
      } // RadGridViewProperties
      
    }

    Reply

  • Brian Sayatovic avatar

    Posted on May 24, 2011 (permalink)

    I tried the original behavior and couldn't get it it work.  Then I tried the attached property one and it works! ...better.  But the empty template shows when there isn't any data AND when there IS data.

    My ItemsSource is bound to an ObservableCollection.  My code clears and populates that ObservableCollection when someone changes a dropdown.  My breakpoint inside EmptyDataTemplateSetVisibility is never reached because 'grid' is null.  Up the stack, the 'sender' of the event isn't the RadgridView but a Telerik.Windows.Data.DataItemCollection.

    Reply

  • Dean Wyant avatar

    Posted on May 24, 2011 (permalink)

    OK, if you are using the property, which property are you using: EmptyText or EmptyDataTemplate?
    Is it set in xaml or code?
    Please paste it so I can see.

    The properties are not in the EmptyDataTemplate class, they are statics in RadGridViewProperties.
    The EmptyDataTemplate class is for attaching in code without using behaviours - it is not set by properties.

    The properties should be much better and they work like so:
    According to which property is set, OnEmptyDataTemplateChanged or OnEmptyTextChanged should be called. Within that method, "grid" is the "DependencyObject" passed so it should not be null. If the DependencyObject is a "DataItemCollection", then the property is being set for the wrong object.

    If you are using the EmptyDataTemplate class (as it sounds like you are), then you have to set it in code like so:

    Somewhere in your code:
            EmptyDataTemplateBehavior EDTB = new EmptyDataTemplateBehavior(grid);

    Or:
            EmptyDataTemplateBehavior EDTB = new EmptyDataTemplateBehavior();
    EDTB.Attach(grid);

    The _grid var will be set directly from what you pass, so it should not be null.

    I imagine that your problem may be something I do not see. More details would be needed to track it down.

    Reply

  • Dean Wyant avatar

    Posted on May 24, 2011 (permalink)

    Never mind, I see the bug. I am looking into it.
    Thanks.

    Reply

  • Brian Sayatovic avatar

    Posted on May 24, 2011 (permalink)

    Hey, no problem.  I appreciate your help!

    As far as I can tell, when the collection changes, the sender isn't the RadGridView but the data collection.  I looked but didn't find a way back to the owning RadGridView from the data collection sender.  I was considering tinkering by using a closure around the grid when attaching the event handlers.

    Reply

  • Dean Wyant avatar

    Posted on May 24, 2011 (permalink)

    I updated the post with the new code. I used a class as a dependency property to hold the grid instance and some of the underlying code.
    I do not know how to use a closure in this instance. Perhaps the code using a closure would be better?
    I kind of like the code with the class because it gets rid of a bunch of static methods.

    I hope this version is bug free... no dangling event handlers, etc. .... no guarantees :-)
    This was put together pretty hastily, so if anyone has bugs, improvements, please post them.
    Thanks.

    Reply

  • Brian Sayatovic avatar

    Posted on May 25, 2011 (permalink)

    This is working great for me.  FWIW, I think closures would've had the same opportunity for memory leaks as the class-based approach you've used.  I think your class-based approach is more understandable though.

    Thank you for sharing this with the community?

    Reply

  • Brian Sayatovic avatar

    Posted on May 25, 2011 (permalink)

    Pavel Pavlov said in April 2009 that this was being scheduled for the [2009] Q2 release:

    "Unfortunately we are missing that feature. I have already talked to my team and we have decided to schedule this  for the Q2 release."

    Whatever happened to that?

    Reply

  • Posted on Aug 11, 2011 (permalink)

    Having trouble with this attached property. Trying to add this to my WPF RadGridView, but when I copied the code I get an error at the XamlReader.Load method. saying "unknown method Load(string).

    How do I fix this so that it works? Thanks for the work on this.

    Reply

  • Dean Wyant avatar

    Posted on Aug 11, 2011 (permalink)

    I think WPF XamlReader.Parse(string) is the equivalent of Silverlight XamlReader.Load(string).

    This was done for the Silverlight control. So, it may need changes for WPF.
    I do not know.

    Reply

  • Posted on Aug 11, 2011 (permalink)

    Thanks. That worked.

    Reply

  • Robert avatar

    Posted on Sep 16, 2011 (permalink)

    Again, what happend to this?

    Pavel Pavlov said in April 2009 that this was being scheduled for the [2009] Q2 release:

    "Unfortunately we are missing that feature. I have already talked to my team and we have decided to schedule this  for the Q2 release."

    Reply

  • UGH!! avatar

    Posted on Sep 20, 2011 (permalink)

    This feature would be nice to have!!

    Reply

  • John Master avatar

    Posted on Oct 4, 2011 (permalink)

    Hi,
    The problem I have with that behavior is that the line 

    Grid rootGrid = gridView.ChildrenOfType<Grid>().FirstOrDefault();

    does never return anything... I can see in the control tree using silverlight spy that some grid controls are present in the childrens but the method never returns anything. I tried other types two. Using the latest version 920...

    any hints on that?
    thanks,
    John.

    Reply

  • Maya Maya admin's avatar

    Posted on Oct 5, 2011 (permalink)

    Hello John,

    Would you clarify what is the exact structure of your application ? Do you define RadGridView in a RadTabControl or any other element ?
     

    Best wishes,
    Maya
    the Telerik team

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

    Reply

  • John Master avatar

    Posted on Oct 5, 2011 (permalink)

    Hi Maya,
    Thank you very much for looking into this...

    This is what I have...

    <UserControl x:Class="SoPratic.SL.Views.CommandesPage">
        <UserControl.Resources>
            <app:CommandesViewModel x:Key="commandesVM"/>
            <ctls:CommandGridStyleSelector x:Key="CellStyleSelector" />
        </UserControl.Resources>
        <Grid x:Name="LayoutRoot" DataContext="{StaticResource commandesVM}">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="400*" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <sdk:Label Grid.Row="0" Content="{Binding CommandDescription, Mode=TwoWay}" HorizontalAlignment="Left" VerticalAlignment="Center" Name="lblOrder" Margin="5,0,0,0" />
            <telerik:RadBusyIndicator Grid.Row="1" Name="busyIndicator" IsBusy="{Binding IsBusy}"
                                BusyContent="Veuillez patienter..." >
                <telerik:RadGridView Name="grdBeneficiaire" IsReadOnly="False" AutoGenerateColumns="False" ShowInsertRow="False"
                                     ItemsSource="{Binding View}" ShowGroupFooters="True" ShowColumnFooters="True" ElementExporting="grdBeneficiaire_ElementExporting"
                                     CanUserInsertRows="False" CanUserDeleteRows="False" RowStyleSelector="{StaticResource CellStyleSelector}"
                                     ScrollViewer.HorizontalScrollBarVisibility="Visible" ScrollViewer.VerticalScrollBarVisibility="Visible" >
                    <i:Interaction.Behaviors>
                        <app:EmptyDataTemplateBehavior>
                            <app:EmptyDataTemplateBehavior.EmptyDataTemplate>
                                <DataTemplate>
                                    <TextBlock Text="Aucune commande en cours de saisie." Foreground="Gray" HorizontalAlignment="Center"  VerticalAlignment="Center" />
                                </DataTemplate>
                            </app:EmptyDataTemplateBehavior.EmptyDataTemplate>
                        </app:EmptyDataTemplateBehavior>
                    </i:Interaction.Behaviors>
                    <telerik:RadGridView.GroupRowStyle >
                        <Style TargetType="telerik:GridViewGroupRow">
                            <Setter Property="ShowHeaderAggregates" Value="True" />
                        </Style>
                    </telerik:RadGridView.GroupRowStyle>
                    <telerik:RadGridView.Columns>
                        <telerik:GridViewDataColumn Header="OdlID" DataMemberBinding="{Binding OdlID}" UniqueName="OdlID" />

    And this is my EmptyDataTemplateBehavior:
    public class EmptyDataTemplateBehavior : Behavior<RadGridView>
        {
            ContentPresenter contentPresenter = new ContentPresenter();
     
            protected override void OnAttached()
            {
                base.OnAttached();
                this.AssociatedObject.LayoutUpdated += new EventHandler(AssociatedObject_LayoutUpdated);
            }
     
            public DataTemplate EmptyDataTemplate { get; set; }
     
            void AssociatedObject_LayoutUpdated(object sender, EventArgs e)
            {
                this.AssociatedObject.LayoutUpdated -= new EventHandler(AssociatedObject_LayoutUpdated);
                this.LoadTemplateIntoGridView(this.AssociatedObject);
                this.AssociatedObject.Items.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(Items_CollectionChanged);
                SetVisibility();
            }
     
            void Items_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
            {
                SetVisibility();
            }
     
            private void SetVisibility()
            {
                if (this.AssociatedObject.Items.Count ==0)
                    this.contentPresenter.Visibility = Visibility.Visible;
                else
                    this.contentPresenter.Visibility = Visibility.Collapsed;
            }
     
            private void LoadTemplateIntoGridView(RadGridView gridView)
            {
                contentPresenter.IsHitTestVisible = false;
                contentPresenter.DataContext = this;
                contentPresenter.ContentTemplate = this.EmptyDataTemplate;
                 
                //TODO make this work
                Grid rootGrid = gridView.ChildrenOfType<Grid>().FirstOrDefault();
                if (rootGrid != null)
                {
                    contentPresenter.SetValue(Grid.RowProperty, 2);
                    contentPresenter.SetValue(Grid.RowSpanProperty, 2);
                    contentPresenter.SetValue(Grid.ColumnSpanProperty, 2);
                    contentPresenter.SetValue(Border.MarginProperty, new Thickness(0, 27, 0, 0));
     
                    rootGrid.Children.Add(contentPresenter);
                }
            }
        }

    Reply

  • Maya Maya admin's avatar

    Posted on Oct 5, 2011 (permalink)

    Hi John,

    Would you try the following:
    1. Remove the line in the LayoutUpdated event:

    this.AssociatedObject.LayoutUpdated -= new EventHandler(AssociatedObject_LayoutUpdated);
     2. and place it here:
    private void LoadTemplateIntoGridView(RadGridView gridView)
            {
      
                contentPresenter.IsHitTestVisible = false;
                contentPresenter.DataContext = this;
                contentPresenter.ContentTemplate = EmptyDataTemplate;
      
                if (gridView.ChildrenOfType<Grid>().Count > 0)
                {
                    Grid rootGrid = gridView.ChildrenOfType<Grid>()[1];
                    contentPresenter.SetValue(Grid.RowProperty, 2);
                    contentPresenter.SetValue(Grid.RowSpanProperty, 2);
                    contentPresenter.SetValue(Grid.ColumnSpanProperty, 2);
                    contentPresenter.SetValue(FrameworkElement.MarginProperty, new Thickness(0, 27, 0, 0));
                    rootGrid.Children.Add(contentPresenter);
                    this.AssociatedObject.LayoutUpdated -= new EventHandler(AssociatedObject_LayoutUpdated);
                }
            }

    Is that approach resolving the issue ? 

    Regards,
    Maya
    the Telerik team

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

    Reply

  • John Master avatar

    Posted on Oct 5, 2011 (permalink)

    Excellent!
    Yes, indeed it works... Very good job...

    I double checked here:
    http://blogs.telerik.com/blogs/posts/10-02-01/empty_data_template_in_radgridview_for_silverlight_and_wpf.aspx
    and the event is not removed, that's why it's working.
    I don't know where taht line comes from.

    Certainely my bad.

    Thanks a lot Maya, I would have been unable to solve this by myself.

    John.

    Reply

  • sandy avatar

    Posted on Jan 27, 2012 (permalink)

    Excellent.
    this code is really helped me a lot for applying emptydatatemplete to multiple radgridview's.

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > GridView > EmptyDataTemplate RadGridView
Related resources for "EmptyDataTemplate RadGridView"

Silverlight Grid Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  ]