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

Generate custom GridViewRows

3 Answers 61 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 01 Jun 2010, 02:02 PM
Hello,

I'm trying to wrap the Telerik (Q1 2010) GridViewRow class within my own CustomGridViewRow implementation. However the items that are generated if I set the ItemsSource are not created correctly if I use a CustomGridView class that extends RadGridView and overrides the IsItemItsOwnContainerOverride and GetContainerFromItem methods.

public class CustomGridView : RadGridView 
    protected override bool IsItemItsOwnContainerOverride(object item) 
    { 
        return (item is CustomGridViewRow); 
    } 
 
    protected override DependencyObject GetContainerFromItemOverride(object item) 
    { 
        return new CustomGridViewRow(); 
    } 
 
public class CustomGridViewRow : GridViewRow 
}

I suppose the problem is my implementation of the GetContainerFromItem method simply returning a new CustomGridViewRow instance which works fine on the RadTabControl to extend the TabItems with Closable support, but there the method signature has no item parameter so I guess I'm missing something here.

I hope someone can point me into the right direction.
Best regards,
Peter

3 Answers, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 01 Jun 2010, 04:30 PM
Hello Peter Payerl,

I am curious to find out why you have chosen to create a custom GridViewRow. There might be an easier way to achieve the desired result. I would really appreciate it if you could give us more details about your requirements.


All the best,
Milan
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
Peter
Top achievements
Rank 1
answered on 01 Jun 2010, 07:04 PM
Hello,

to be honest so far there is no real reason for wrapping the GridViewRow so we can go with the standard one as well.
However after creating our CustomTabControl with its ClosableTabItem support we thought it would be neat to wrap the GridView and its components as well (for instance to avoid an additional namespace in the majority of our XAML files besides the one we use for our custom controls).
And of course the most important reason: my curiousity how this could be done when I could not figure it out myself ;)

Best regards,
Peter
0
Milan
Telerik team
answered on 07 Jun 2010, 09:38 AM
Hello Peter Payerl,

Once way to do this is with the following code:

public class CustomGridViewRow : GridViewRow
{
    public CustomGridViewRow()
    {
          
    }
  
    protected override void OnInitialized(EventArgs e)
    {
        base.OnInitialized(e);
  
        this.DefaultStyleKey = ThemeResourceKey.GetDefaultStyleKey(new Office_BlackTheme(), typeof(GridViewRow));
    }
}

Best wishes,
Milan
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.
Tags
GridView
Asked by
Peter
Top achievements
Rank 1
Answers by
Milan
Telerik team
Peter
Top achievements
Rank 1
Share this question
or