How can I stop the property window from resizing with content

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

    Posted 14 Jun 2012 Link to this post

    I have a property grid and it shows a scroll bar when the text is to long.  I want it to work like in visual studio where there is no huge ugly scroll bar at the buttom of the grid.  I have tried changing the "Scroll Viewer" for the grid but it dosn't seem to do anything.  It is in a dockable window so I can not just set the width of the text box as well.
  2. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1128 posts

    Posted 14 Jun 2012 Link to this post

    Hello Alex,

    You can set hard-coded Width value for both fields and RadPropertyGrid itself, like this:
    <Grid>
            <Grid.Resources>
                <Style TargetType="telerik:PropertyGridField">
                    <Setter Property="Width" Value="400" />
                </Style>
            </Grid.Resources>  
            <telerik:RadPropertyGrid x:Name="rpg" Item="{Binding Employee}" Width="402">            
            </telerik:RadPropertyGrid>
        </Grid>


    Kind regards,
    Ivan Ivanov
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Alex
    Alex avatar
    34 posts
    Member since:
    Jun 2009

    Posted 14 Jun 2012 Link to this post

    I can't do that.
  5. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1128 posts

    Posted 14 Jun 2012 Link to this post

    Hi,

    Another option would be to subscribe to RadPropertyGrid's Loaded event and disable scrollviewer's horizontal scrolling like this:
    private void rpg_Loaded(object sender, RoutedEventArgs e)
    {
        (sender as RadPropertyGrid).ChildrenOfType<ScrollViewer>().First(sv => sv.Name == "PART_ItemsScrollViewer").HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
    }
    Alternatively you may modify RadPropertyGrid's template setting HorizontalScrollBarVisibility there.

    Kind regards,
    Ivan Ivanov
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  6. Alex
    Alex avatar
    34 posts
    Member since:
    Jun 2009

    Posted 14 Jun 2012 Link to this post

    Thank you that was what I needed.
  7. Felix
    Felix avatar
    17 posts
    Member since:
    Jun 2011

    Posted 11 Jul 2013 Link to this post

    I can not find any ScrollViewer in the Control Template of the RPG. Your code (for the Loaded Event) throws an Exception.

    I am using the most current Version/Hotfix of Q2.2013 from July, 8.

    How to disable the horizontal Scrollbar with the current version?

    Thanks
    Felix
  8. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 16 Jul 2013 Link to this post

    Hello Felix,

    The thing is that we have made some improvement on introducing virtualization and this scroll viewer is not present. What you need to do now is to find the one in the PropertyGridPresenter:

    private void propertyGrid_Loaded(object sender, RoutedEventArgs e)
            {
                var proeprtyGridPresenter = this.propertyGrid.ChildrenOfType<PropertyGridPresenter>().FirstOrDefault();
                if (proeprtyGridPresenter != null)
                {
                    var scrollViewer = proeprtyGridPresenter.ChildrenOfType<ScrollViewer>().FirstOrDefault();
                    if (scrollViewer != null)
                    {
                        scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
                    }          
                }
            }

    I hope this does not cause much trouble on your side.  

    Regards,
    Maya
    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. Felix
    Felix avatar
    17 posts
    Member since:
    Jun 2011

    Posted 16 Jul 2013 Link to this post

    Hello Maya,

    this works great. Thank you!

    Felix
Back to Top
UI for WPF is Visual Studio 2017 Ready