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

horizontal scrollbar

9 Answers 103 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
tomas
Top achievements
Rank 1
tomas asked on 04 Jul 2013, 11:52 AM
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

9 Answers, 1 is accepted

Sort by
0
tomas
Top achievements
Rank 1
answered on 04 Jul 2013, 01:03 PM
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

0
Maya
Telerik team
answered on 09 Jul 2013, 12:22 PM
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 >>
0
tomas
Top achievements
Rank 1
answered on 09 Jul 2013, 03:53 PM
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

0
Maya
Telerik team
answered on 10 Jul 2013, 07:55 AM
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 >>
0
WILLIAM
Top achievements
Rank 1
answered on 26 Jul 2013, 08:38 PM
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>
0
WILLIAM
Top achievements
Rank 1
answered on 30 Jul 2013, 01:02 PM
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);
}
0
JOHN
Top achievements
Rank 1
answered on 30 Sep 2013, 04:01 PM
Maya,

Do we have a good solution on this?
0
tomas
Top achievements
Rank 1
answered on 30 Sep 2013, 04:04 PM
I need it too!

thank you...

Tom
0
Maya
Telerik team
answered on 03 Oct 2013, 12:46 PM
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 >>
Tags
PropertyGrid
Asked by
tomas
Top achievements
Rank 1
Answers by
tomas
Top achievements
Rank 1
Maya
Telerik team
WILLIAM
Top achievements
Rank 1
JOHN
Top achievements
Rank 1
Share this question
or