This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I use a custom PropertyEditor to set the value of a property by selecting an object from a list. The EditorTemplate is a DataTemplate consisting solely of a ComboBox whose ItemsSource is bound to a CollectionViewSource containing the list of objects. The PropertyGrid's SelectedObject is chosen by the user from a ListBox (and the initial value of the target property on the selected item is null). When an item is selected from the ListBox, the PropertyGrid shows the property's node with the ComboBox and its dropdown list contains the objects, as expected. However, the width of the initial dropdown control extends beyond the right side of the PropertyGrid -- way beyond. As soon as the dropdown control is clicked to reveal the ComboBox's list, the dropdown control resizes itself so its width is correctly within the PropertyGrid. (The control will also resize itself correctly if the containing Window is resized in either direction.) This happens every time the SelectedObject changes, whether the property's value is null or set to one of the items in the list. To demonstrate the problem, I've attached a sample program (a simplified version of one I submitted on an earlier post). To see how wide the control tries to extend itself when it's first displayed, I set the MainWindow's SizeToContent property to "Width". With that setting, the MainWindow is initially wide enough to fit the contents of the ListBox at the top. But when an item in the ListBox is selected, the ComboBox pushes the right side of the MainWindow all the way across the screen. Also note that the arrow on the right side of the ComboBox's dropdown control is not visible -- it's been pushed beyond the limit of the window and is clipped by the window's border. If you click the dropdown, the MainWindow resizes itself to it's initial size and the dropdown's arrow is now visible. (Clicking off the ComboBox causes no resizing and the arrow is still visible; selecting one of the ComboBox's items causes the MainWindow to resize itself to fit the contents again and the arrow remains visible.) To see if constraining the Window size would make a difference, I removed the SizeToContent setting and specified a Width. (Comment the existing Window tag and uncomment the commented tag below it.) With that setting, the MainWindow is initially displayed with the specified width. Clicking an item in the ListBox causes the PropertyGrid to display the editor's ComboBox, but note that its down arrow is not visible -- it's been clipped by the edge of the PropertyGrid. Clicking it brings the width back inside the PropertyGrid and the arrow is visible again. With the Window SizeToContent="Width", Snoop shows the following properties of the ComboBox's when it's initially displayed (wide): ActualWidth = 3579 DesiredSize = 28,21.96 Width = NaN. On clicking the dropdown (the arrow now becomes visible): ActualWidth = 48.37 DesiredSize = 28,21.96 Width = NaN. With the Window Width="360", Snoop shows the following properties of the ComboBox's when it's initially displayed (wide): ActualWidth = 319 (still too wide, considering the whole PropertyGrid has an ActualWidth of 320) DesiredSize = 28,21.96 Width = NaN. On clicking the dropdown (the arrow now becomes visible): ActualWidth = 270.37 DesiredSize = 28,21.96 Width = NaN. Enclosing the ComboBox in a Grid, StackPanel, or DockPanel does not solve the problem. I have also seen this occurring in a custom PropertyEditor whose DataTemplate consisted of a TextBox with an ellipses button to its right (following the instructions in the Help file). In that case the ellipses button was pushed off the right side of the PropertyGrid and clipped. It becomes visible again as soon as the text in the TextBox was changed or the MainWindow is resized. How can I prevent this from happening? |
|
|
Hello BillBR Thanks for pointing this out and sending us the repro project. This clipping issue will be resolved in the next nightly build. Jason Fauchelle |
|
|
Thanks for the quick fix for this issue, Jason. It works well in our app. I did note however that in the sample code case where the SizeToContent="Width" is used instead of specifying the width, the behavior is still a bit odd. When an item is selected in the list, the window initially stretches all the way to the right side of the screen to accommodate the ComboBox (as it did before) and then incrementally resizes itself back to the expected width and the ComboBox is the correct size. You may want to see if you can prevent the 'flashing' through some sort of delayed rendering. In the meantime, this works for us. Thanks again, BillBR |
|