horizontal scrollbar

10 posts, 0 answers
  1. tomas
    tomas avatar
    139 posts
    Member since:
    Sep 2012

    Posted 04 Jul 2013 Link to this post

    Hi TElerik,

    I would like to turn off the horizontal scrollbar.

    I have found some similar questions here, but the mentioned code did not find the scrollwiever.

    I would like to achieve the same result as in a visual studio properties pane.

    Can you help me please?

    Thank you.

    Tom
  2. tomas
    tomas avatar
    139 posts
    Member since:
    Sep 2012

    Posted 04 Jul 2013 Link to this post

    Ok, I have found the scrollbar:

    presenter = grid.ChildrenOfType<PropertyGridPresenter>().First();

    scroll_viewer = presenter.ChildrenOfType<ScrollViewer>().FirstOrDefault();

    if (scroll_viewer != null)

    scroll_viewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden;

    But it is not working as expected. My Textboxes in datatemplates of propertydefinitions are set with HorizontalAlingment=Strech. RadPropertyGrid is insade docking panel. It can grow indefinitely. How can I allow to grow only to the available dock pane with - label column with?

    Thank you very much.

    Tom

  3. DevCraft banner
  4. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 09 Jul 2013 Link to this post

    Hi Tomas,

    Generally, you can set LabelColumnWidth property to "*"so that the label takes all the available space rather than its default value of 200. Could you take a look at the sample attached to see whether this is what you expect ? If not, could you update it and send it back so that I can check what your exact requirements are ? 

    Regards,
    Maya
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    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 >>
  5. tomas
    tomas avatar
    139 posts
    Member since:
    Sep 2012

    Posted 09 Jul 2013 Link to this post

    Hello Telerik,

    Setting the labelColumnWith to * is exactly the opposite what I need.

    I need that the second column (valueColumnWith) could be set to *.

    But the propertyGrid with should be only the visible with of rad pane and it should not grow indefinitely.

    It should be the same behavior as the Property Pane in a Visual Studio.

    Thank you very much.

    Tom

  6. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 10 Jul 2013 Link to this post

    Hi Tomas,

    The template of the PropertyGridField is separated into three columns: 

    <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="{Binding LabelColumnWidth, ElementName=PropertyGridPresenter}"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>

    The first one is for the indicator at leftmost, the second is for the display names and the last one is for the values and it fills the whole space. And since dock panels measure its children with infinity, the last column will try to fill up the space. 
    What you can try is to set the Width property of the property grid.  

    Regards,
    Maya
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    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 >>
  7. WILLIAM
    WILLIAM avatar
    134 posts
    Member since:
    Jun 2012

    Posted 26 Jul 2013 Link to this post

    It seems that this is the set of column definitions I need to get to.  How do I find it?  Does the grid that this set of column definitions belongs to have a name?  I'm going up and down the visual tree and haven't found it yet.

    Doesn't it seem easy and obvious that there could have been a ValueColumnWidth?

    <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="{Binding LabelColumnWidth, ElementName=PropertyGridPresenter}"/>
                            <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
  8. WILLIAM
    WILLIAM avatar
    134 posts
    Member since:
    Jun 2012

    Posted 30 Jul 2013 Link to this post

    While waiting on a more elegant solution from telerik that never came, I found a work around solution on my own.  It's not pretty, but so far it seems to meet for our needs.  The only way I have figured out to make sure that textboxes wrap, is to size/resize the value controls in the property grid so that you never need the horizontal scroll bar.  I do this by setting the MaxWidth of all of the value controls dynamically.  Doing this seems to work and textbox controls wrap when needed.  I dynamically set this property when the PropertyGrid is first created and when it's resized. It's not perfect a solution, but close.  The last snippet of code shows how I'm setting the MaxWidth property for one of our controls, but it has to be done for all controls; except probably a checkbox.

    Telerik, this may have helped.  
    <ColumnDefinition Width="{Binding ValueColumnWidth, ElementName=PropertyGridPresenter}"/>"

    Or give us an easy way to find the column definitions that Thomas pointed out for these three columns so that we set the column widths them as needed.

    public IPropertyGridConfigurationManagerSettings Initialize(RadPropertyGrid propertyGrid)
    {
        PropertyGrid.Loaded += PropertyGridOnLoaded;
        PropertyGrid.SizeChanged += PropertyGridOnSizeChanged;
     
        return this;
    }
     
    private void PropertyGridOnLoaded(object sender, RoutedEventArgs routedEventArgs)
    {
        ScrollViewer = PropertyGrid.ChildrenOfType<ScrollViewer>().First();
    }
             
    private void PropertyGridOnSizeChanged(object sender, SizeChangedEventArgs sizeChangedEventArgs)
    {
        var valueControlWidth = GetControlMaxWidth();
        PopulateProperyDefinitions(valueControlWidth);
    }
     
    private ScrollViewer ScrollViewer { get; set; }
    private const double IndicatorWidth = 30;  // I'm only guessing at this value
     
    private double GetControlMaxWidth()
    {
        var propertyLabelWidth = PropertyGrid.LabelColumnWidth.Value;
        return ScrollViewer.ViewportWidth - (IndicatorWidth + propertyLabelWidth);
    }
             
    public static DataTemplate DataTemplateMemoEdit(IDynamicProperty dynamicProperty, double maxWidth)
    {
        var dataTemplate = new StringBuilder();
        dataTemplate.Append("<TextBox ");
        dataTemplate.Append("AcceptsReturn='true' ");
        dataTemplate.Append("Height='Auto' ");           
        dataTemplate.Append("Text='{Binding [" + dynamicProperty.Name + "], Mode=TwoWay}' ");
        dataTemplate.Append("TextWrapping='Wrap' ");
        dataTemplate.Append(String.Format("Name='ux{0}' ", dynamicProperty.Name));
        dataTemplate.Append(String.Format("MaxWidth='{0}' ", maxWidth));
        dataTemplate.Append("/>");
        var dataTemplateString = String.Format(__dataTemplatePattern, dataTemplate);
        return (DataTemplate)XamlReader.Load(dataTemplateString);
    }
  9. JOHN
    JOHN avatar
    2 posts
    Member since:
    Apr 2012

    Posted 30 Sep 2013 Link to this post

    Maya,

    Do we have a good solution on this?
  10. tomas
    tomas avatar
    139 posts
    Member since:
    Sep 2012

    Posted 30 Sep 2013 Link to this post

    I need it too!

    thank you...

    Tom
  11. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 03 Oct 2013 Link to this post

    Hi Tomas,

    In case your scenario is like before - RadPropertyGrid in RadPane - you need to set Width property of the property grid. Since RadPane measures its children with infinity, you need to specify the space the last column (the one holding the values) should take.  

    Regards,
    Maya
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    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
DevCraft banner