How to detect when the first column is resized.

15 posts, 0 answers
  1. Alex
    Alex avatar
    34 posts
    Member since:
    Jun 2009

    Posted 25 Jul 2013 Link to this post

    I need to know how to detect when the label column of a property grid is resized.
  2. Yoan
    Admin
    Yoan avatar
    1070 posts

    Posted 26 Jul 2013 Link to this post

    Hi Alex,

    You can try to use ChildrenOfType<>() extension method and find the underlying element. In your case it will be the PropertyGridColumnResizer. Please check the following code snippet for a reference:

    var cr = this.propertyGrid.ChildrenOfType<PropertyGridColumnResizer>().FirstOrDefault().ChildrenOfType<Thumb>().FirstOrDefault();
      
    cr.DragDelta += new DragDeltaEventHandler(cr_DragDelta);   
     
    void cr_DragDelta(object sender, DragDeltaEventArgs e)
    {
        
    }

    Regards,
    Yoan
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Alex
    Alex avatar
    34 posts
    Member since:
    Jun 2009

    Posted 26 Jul 2013 Link to this post

    .ChildrenOfType<Thumb>() I returning null.

  5. Yoan
    Admin
    Yoan avatar
    1070 posts

    Posted 26 Jul 2013 Link to this post

    Hi Alex,

    Can you please try to add the above code in RadPropertyGrid's Loaded event:

    private void propertyGrid_Loaded(object sender, RoutedEventArgs e)
          {
              var cr = this.propertyGrid.ChildrenOfType<PropertyGridColumnResizer>().FirstOrDefault().ChildrenOfType<Thumb>().FirstOrDefault();
              cr.DragDelta += new DragDeltaEventHandler(cr_DragDelta);          
          }

    Please let me know about the result.


    Regards,
    Yoan
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  6. Alex
    Alex avatar
    34 posts
    Member since:
    Jun 2009

    Posted 26 Jul 2013 Link to this post

    Still returning null. 

    this.pgSpectrums.ChildrenOfType<PropertyGridColumnResizer>().FirstOrDefault().ChildrenOfType<Thumb>().Count()

    is returning 

     'this.pgSpectrums.ChildrenOfType<PropertyGridColumnResizer>().FirstOrDefault().ChildrenOfType<Thumb>().Count()' threw an exception of type 'System.ArgumentNullException' int {System.ArgumentNullException}
  7. Alex
    Alex avatar
    34 posts
    Member since:
    Jun 2009

    Posted 26 Jul 2013 Link to this post

    actually

    this.pgSpectrums.ChildrenOfType<PropertyGridColumnResizer>().Count() is 0 so that's the problem.
  8. Yoan
    Admin
    Yoan avatar
    1070 posts

    Posted 26 Jul 2013 Link to this post

    Hi Alex,

    I've tried to reproduce the problem you report, but to no avail. I have attached my test project for a reference.

    Regards,
    Yoan
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  9. Alex
    Alex avatar
    34 posts
    Member since:
    Jun 2009

    Posted 26 Jul 2013 Link to this post

    I'm using version 2013.1.403.40 your using 2013.2.611.40, could that be the problem?
  10. Yoan
    Admin
    Yoan avatar
    1070 posts

    Posted 26 Jul 2013 Link to this post

    Hello Alex,

    Indeed, you are right about that. May I ask you to test your project with our latest binaries?

    Regards,
    Yoan
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  11. Alex
    Alex avatar
    34 posts
    Member since:
    Jun 2009

    Posted 26 Jul 2013 Link to this post

    I don't have access to that apparently.  I can only download the one I have.
  12. Yoan
    Admin
    Yoan avatar
    1070 posts

    Posted 26 Jul 2013 Link to this post

    Hi Alex,

    Actually, you can download our latest binaries from your account :

    Products & Subscriptions -> Trial downloads -> RadControls for WPF -> Download -> download a file.

    I hope this helps.

    Regards,
    Yoan
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  13. Alex
    Alex avatar
    34 posts
    Member since:
    Jun 2009

    Posted 26 Jul 2013 Link to this post

    I still get the same error.
  14. Alex
    Alex avatar
    34 posts
    Member since:
    Jun 2009

    Posted 26 Jul 2013 Link to this post

    Figured out the problem, it was calling the load even if it is not shown (which it wasn't').  Fixed that.  Still doesn't do what I want.  Even your example didn't call the function when I changed the width of the label column.
  15. Alex
    Alex avatar
    34 posts
    Member since:
    Jun 2009

    Posted 29 Jul 2013 Link to this post

    This code isn't working either.  I thought maybe I wasn't using the correct thumb and it's not working

    foreach (PropertyGridColumnResizer clsProperty in this.pgSpectrums.ChildrenOfType<PropertyGridColumnResizer>())
                    {
                        foreach (Thumb clsThumb in clsProperty.ChildrenOfType<Thumb>())
                        {
                            clsThumb.DragDelta += new DragDeltaEventHandler(cr_DragDelta); 
                        }
                    }
  16. Yoan
    Admin
    Yoan avatar
    1070 posts

    Posted 31 Jul 2013 Link to this post

    Hi Alex,

    You can try to subscribe to RadPropertyGrid's FieldLoaded event like so:

    private void propertyGrid_FieldLoaded(object sender, FieldEventArgs e)
            {
                Dispatcher.BeginInvoke((Action)(() =>
                {
                    var cr = e.Field.ChildrenOfType<PropertyGridColumnResizer>().FirstOrDefault().ChildrenOfType<Thumb>().FirstOrDefault();
                    
             cr.DragDelta += new DragDeltaEventHandler(cr_DragDelta);
                    
                }));           
            }
     
            void cr_DragDelta(object sender, DragDeltaEventArgs e)
            {
     
            }

    Please let me know how it goes.


    Regards,
    Yoan
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top
UI for WPF is Visual Studio 2017 Ready