Deriving from RadGridView

3 posts, 0 answers
  1. Aaron
    Aaron avatar
    38 posts
    Member since:
    Apr 2008

    Posted 31 Mar 2015 Link to this post

    My RadGridView instances always have several properties that are set exactly the same way. Something like this:

    <telerik:RadGridView  RowIndicatorVisibility="Collapsed"  AllowDrop="False" AutoGenerateColumns="False" CanUserDeleteRows="False" CanUserReorderColumns="False" GridLinesVisibility="Both" ShowGroupPanel="False" ShowColumnHeaders="True" IsFilteringAllowed="False" CanUserFreezeColumns="False" CanUserInsertRows="False" >...</telerik:RadGridView>

    So I thought, why not derive from this control and set those properties in the constructor?  I wrote this class that extends RadGridView:

    namespace MyUI
     public class MyGridView : Telerik.Windows.Controls.RadGridView
            public MyGridView()
                : base()
                this.RowIndicatorVisibility = System.Windows.Visibility.Collapsed;
                this.AllowDrop = false;
                this.AutoGenerateColumns = false;
                this.CanUserDeleteRows = false;
                this.CanUserReorderColumns = false;
                this.GridLinesVisibility = Telerik.Windows.Controls.GridView.GridLinesVisibility.Both;
                this.ShowGroupPanel = false;
                this.ShowColumnHeaders = true;
                this.IsFilteringAllowed = false;
                this.CanUserFreezeColumns = false;
                this.CanUserInsertRows = false;

    Okay, so using this should be as simple as this:

    <Window ...
    <local:MyGridView >...</local:MyGridView>

    It won't compile.  I get an error that says "The name 'MyGridView' does not exist in the namespace 'clr-namespace:MyUI'".

    I've tried declaring the namespace with and without the "assembly=MyUI" part.  

    What am I doing wrong here?


  2. Dimitrina
    Dimitrina avatar
    3769 posts

    Posted 01 Apr 2015 Link to this post

    Hi Aaron,

    Is this the only error you get? Does it compile fine if you remove the following line:
    <local:MyGridView >...</local:MyGridView>

    If so, then would you please share if you use the full binaries, or NoXaml ones?


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

  3. Aaron
    Aaron avatar
    38 posts
    Member since:
    Apr 2008

    Posted 01 Apr 2015 in reply to Dimitrina Link to this post

    Strangely, it now works.  I think I just needed to restart Visual Studio, but not sure why.

    I am using binaries, and I added the namespace without the "assembly=MyUI" part.

Back to Top