In our application we use the autogenerate property grid fields mechanism. The property grid is located in a radpane (RadDocking) like in visual studio. The LabelColumnWidth of the property grid is set to 100px.
We have the problem that long string values (f.i. file paths) in the property grid value column cause horizontal scrolling. Is there any possibility to disable the horizontal scrolling if the values of property fields are to long for the field?
We would like to have an autoresizing property grid. If the user increases the size of the dock the label column stays on 100px while the value column width increases to the the size: width of the RadPane - width of the column value.
That would be the behaviour I would expect.
Thanks and best regards,
Simon
12 Answers, 1 is accepted
For your convenience, I prepared an example to demonstrate how to achieve the desired behavior. Please take a look at the implementation and consider how this approach fits your scenario.
I hope that this helps. Should you have any other questions, do not hesitate to contact us.
Regards,
Martin Vatev
Telerik by Progress
Thank you for sharing your idea. We appreciate every feedback from our customers. You are right that this functionality can be further improved. For any functionality that you find useful and we do not have it implemented in our control you can use our feedback portal to submit a feature request. Once the feature is approved everyone can vote for its implementation. By voting the priority of the item gets increased.
Regards,
Dinko
Progress Telerik
I have this same problem, but when I try the sample code, I get an error message that it contains no elements.
That is, there are no children of type <VirtualizingStackPanel> my PropertyGrid.
Any ideas on how to fix that?
Hi Reese,
I have double-checked the attached project from my colleague Martin, but haven't got any error message. May I ask you to specify where this message error is thrown and the steps to reproduce it. Do I need to modify the project? Any additional information is highly appreciated.
Regards,
Dinko
Progress Telerik
Thanks for responding.
I never resolved the error, but I did find another workaround. I first created a Data Template for the TextBox:
<DataTemplate x:Key="TextBoxTemplate">
<TextBox x:Name="PropertyTextBox"
Loaded="PropertyTextBox_Loaded"
HorizontalAlignment="Left"
Width="250"/>
</DataTemplate>
And then, I added the following code to the AutoGeneratingProperty event to apply that template:
if (e.PropertyDefinition.SourceProperty.PropertyType.Name == "String" && e.PropertyDefinition.EditorTemplate == null)
{
//This works along with the "TextBoxTemplate" and the PropertyTextBox_Loaded method to limit the width of the TextBox
DataTemplate dt = (DataTemplate)this.Resources["TextBoxTemplate"];
e.PropertyDefinition.EditorTemplate = dt;
}
Finally, I added this code to the Loaded event for the data template TextBox:
private void PropertyTextBox_Loaded(object sender, RoutedEventArgs e)
{
//This works along with the "TextBoxTemplate" to limit the width of the TextBox
if (sender is TextBox)
{
TextBox tb = (TextBox)sender;
string propertyName = ((Telerik.Windows.Controls.Data.PropertyGrid.PropertyDefinition)((PropertyGridField)tb.Parent).DataContext).AutoGeneratedPath;
Binding b = new Binding(propertyName);
b.Mode = BindingMode.TwoWay;
tb.SetBinding(TextBox.TextProperty, b);
}
}
Hello Reese,
I am happy to hear that you have a workaround for this behavior and thank you for sharing it. If you have any other questions you can open a new forum thread with your questions inside.
Regards,
Dinko
Progress Telerik
I get the same error as Reese.
I have not made any changes to the project and ran it, 'as is'.
Exception thrown: System.InvalidOperationException
HResult=0x80131509
Message=Sequence contains no elements
Source=System.Core.
Hello Allistair,
Thank you for the provided error details.
I still wasn't able to reproduce this error. My guess here it comes from the different assemblies version used on your side. Can you share which version of our DLLs are you referencing? I am re-attaching the sample project with a trial version of our assemblies. This way you can just download it and run it directly. Give it a try and let me know if you reproduce this error again.
Regards,
Dinko
Progress Telerik
Hello Johnathan,
Thank you for the provided images.
I have double-checked the project from my previous reply, but such an exception does not appear on my side. Can you confirm that you haven't made any changes to the code inside? If you have, can you share what changes are added. Also, just for the test, can you change the DispatcherPriority inside the Loaded event to ApplicationIdle and let me know if it makes any difference.
private void PropertyGrid1_Loaded(object sender, RoutedEventArgs e)
{
Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new Action(() =>
{
(sender as RadPropertyGrid).ChildrenOfType<VirtualizingStackPanel>().First().ScrollOwner.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
}));
}
Regards,
Dinko
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products, quickly just got a fresh new look + new and improved content, including a brand new Blazor course! Check it out at https://learn.telerik.com/.