RadGridView inside radexpander content

1 Answer 107 Views
Expander GridView
Deltaohm
Top achievements
Rank 3
Bronze
Iron
Iron
Deltaohm asked on 07 Feb 2022, 03:36 PM

Hi,

I have a list of RadExpander, inside every Radexpander there is a Radgridview. When  I expand, expander height grow over the size of window and a scroll bar appears in expander control itself.
I would like that expander doesn't grow over the window and the scroll bar appears in the gridview. I could achieve this behaviour setting maxheight in gridview, but I don't want to limit the height of grid.In first attachment the situation when maxheight is not set, in the second with maxheight set, I would achieve the second situation but without setting maxheight.

Thank you

Luigi

 

Below it is the xaml as appears in LiveVisualTree: I think that the real one it is too much complex to understand the situation quickly.


<Grid x:Uid="Grid_1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<t:RadDocking x:Name="radDocking1"
                            RetainPaneSizeMode="DockingAndFloating"
                            CanAutoHideAreaExceedScreen="True"
                            Grid.Row="1" Margin="0 0 0 10"                            
                            BorderThickness="0"
CloseButtonPosition="InPane"
                            Padding="0"
  Close="radDocking1_Close"
  PaneStateChange="radDocking1_PaneStateChange">
<t:RadSplitContainer 
MinWidth="310"
MaxWidth="600" t:DockingPanel.InitialSize="260,150"
                    Name="RightContainer" InitialPosition="DockedRight">
<t:RadPaneGroup >
<t:RadPane>
<t:RadPanelBar 
HorizontalContentAlignment="Stretch"
ExpandMode="Multiple" Name="PanelBarCursor"
t:StyleManager.Theme="Office_Blue"
ScrollViewer.VerticalScrollBarVisibility="Visible">
<t:RadPanelBarItem 
VerticalAlignment="Top"
HorizontalContentAlignment="Left"
Header="{DynamicResource CursoriAssociati}">
<StackPanel>
<t:RadListBox ItemsSource="{Binding TabCursori.Cursori}" 
  SelectionMode="Single"
  Loaded="RadListBox_Loaded"
  SelectedItem="{Binding TabCursori.SelectedCursor}">
<t:RadExpander t:AnimationManager.IsAnimationEnabled="false" IsExpanded="{Binding IsExpanded, Mode=TwoWay}">
<t:RadExpander.Content>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<t:RadGridView 
MaxHeight="250"
ItemsSource="{Binding PositionsY}"
CanUserDeleteRows="False"
CanUserInsertRows="False"
RowIndicatorVisibility="Collapsed"
AutoGenerateColumns="False"
ShowColumnHeaders="False"
ShowColumnFooters="False"
ShowGroupPanel="False"
ShowScrollPositionIndicator="False"
ShowSearchPanel="False"
SelectedItem="{Binding 
RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=t:RadDocking},
Path=DataContext.TabCursori.PositionHilight}"
   IsReadOnly="True">
<t:RadGridView.Resources>
<Style TargetType="t:GridViewRow">
<Setter Property="SelectedBackground" Value="Bisque"/>
</Style>
</t:RadGridView.Resources>
<t:RadGridView.Columns>
<t:GridViewDataColumn DataMemberBinding="{Binding ParameterName}" Width="100"/>
<t:GridViewDataColumn DataMemberBinding="{Binding ParameterValue, StringFormat=N1}" Width="80"/>
</t:RadGridView.Columns>
</t:RadGridView>
<!--<TextBlock Text="{Binding Internal.PositionY, StringFormat={}{0:F4}}"
   Visibility="{Binding PositionYVisibility, Converter={StaticResource BoolToVis}}"/>-->
</Grid>
</t:RadExpander.Content>
</t:RadExpander>
</t:RadPanelBarItem >
</t:RadPanelBar>
</t:RadPane>
</t:RadSplitContainer >
</t:RadDocking>
</grid>

1 Answer, 1 is accepted

Sort by
0
Accepted
Martin Ivanov
Telerik team
answered on 10 Feb 2022, 01:08 PM

Hello Gianluca,

What happens is that the RadExpander control gives its content as much space as it needs to render. For example, if you have a RadGridView with 100 rows, the expander will give the content as much space as the GridView needs to render all those 100 rows (not the size of the window). The scroll viewer that appears seems to be the one of the control that hosts the RadExpander elements.

In order to achieve your requirement, you will need to limit the height of the GridView. This is also required in order to enable the UI virtualization, thus boosting the performance of the GridView. You can do that by setting the Height or MaxHeight properties of GridView. If you want to make it a bit more dynamic and maybe related to the current size of the window, you can use the SizeChanged event of the window to calculate how much space the RadGridView can get.

Regards,
Martin Ivanov
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/.

Tags
Expander GridView
Asked by
Deltaohm
Top achievements
Rank 3
Bronze
Iron
Iron
Answers by
Martin Ivanov
Telerik team
Share this question
or