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

scroll - Grid inside a StackPanel

7 Answers 234 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Orit
Top achievements
Rank 1
Orit asked on 14 Sep 2009, 08:30 AM
Hi
I have a Grid inside a StackPanel
when I click on an expand button
something very strange happens:
it looks like the scrolls are flashing:
appear and disappear .. appear and disappear .. appear and disappear

this is my xaml

<GroupBox Name="gbAccountManagment" Margin="2,2,2,2" MaxHeight="580" Height="480" VerticalAlignment="Top" > 
                <GroupBox.Header> 
                    <Grid> 
                        <Grid.ColumnDefinitions> 
                            <ColumnDefinition></ColumnDefinition>  
                            <ColumnDefinition></ColumnDefinition>  
                        </Grid.ColumnDefinitions> 
                        <Button Grid.Column="0" Name="btnAccountManagmentPlus" Visibility="Hidden" Width="20" Click="btnAccountManagmentPlus_Click">+</Button> 
                        <Button Grid.Column="0"  Name="btnAccountManagmentMinus"  Width="20" Click="btnAccountManagmentMinus_Click">-</Button> 
                        <Label Grid.Column="1">ניהול חשבונות</Label> 
                    </Grid> 
                </GroupBox.Header> 
                <StackPanel > 
                    <StackPanel Orientation="Horizontal">  
                        <TextBlock Margin="100,5,5,5" FontWeight="Bold" Width="60">סוג תקציב</TextBlock> 
                        <ComboBox Name="cmbBudgetType" DisplayMemberPath="Name" Margin="5,5,5,5" Width="120" SelectionChanged="cmbBudgetType_SelectionChanged"></ComboBox> 
                        <TextBlock Margin="100,5,5,5" FontWeight="Bold" Width="60">סוג פעילות</TextBlock> 
                        <ComboBox Name="cmbActivityType" DisplayMemberPath="Name" Margin="5,5,5,5" Width="120" SelectionChanged="cmbActivityType_SelectionChanged"></ComboBox> 
                        <Button Name="btnFilter" Margin="30,5,5,5" Click="btnFilter_Click">הצג</Button> 
                        <Button Visibility="Hidden" Name="btnTry" Margin="30,5,5,5" Click="btnTry_Click">Try</Button> 
                    </StackPanel> 
                    <StackPanel> 
                      <StackPanel.Resources> 
                        <Style x:Key="ToolTipColumnStyle" TargetType="telerik:GridViewCell">  
                            <Setter Property="ToolTip" Value="{Binding Content,RelativeSource={RelativeSource Self}}" /> 
                        </Style> 
                    </StackPanel.Resources> 
                      <telerik:RadGridView Name="gvAccount" Margin="5,5,5,5" AutoGenerateColumns="False"   
                                         CanUserResizeColumns="False" CanUserReorderColumns="False" ScrollMode="RealTime" 
                                         CanUserFreezeColumns="False" ShowGroupPanel="False" CanUserSortColumns="False" 
                                         FlowDirection="RightToLeft" IsFilteringAllowed="False" ShowColumnHeaders="True" CanUserInsertRows="False">  
                        <telerik:RadGridView.Columns> 
                            <telerik:GridViewDataColumn IsReadOnly="True" UniqueName="BudgetTypeName" Header="תקציב"  Width="60"/>  
                            <telerik:GridViewDataColumn IsReadOnly="True" UniqueName="Name" Header="שם חשבון/&#13;סעיף/תת סעיף"  Width="160" CellStyle="{StaticResource ToolTipColumnStyle}"/>                                  
                            <telerik:GridViewDataColumn IsReadOnly="True" UniqueName="DisplayNum" Header="מס' חשבון/&#13;סעיף/תת סעיף" Width="110" /> 
                            <telerik:GridViewDataColumn IsReadOnly="True" DataFormatString="{}{0:#,##0.00₪}" UniqueName="TotalBudget" Header="הקצבה&#13;כוללת&#13;(אש''ח)"  Width="75"/>  
                            <telerik:GridViewDataColumn IsReadOnly="True" DataFormatString="{}{0:#,##0.00₪}" UniqueName="BalanceBudgetAllocation" Header="יתרה&#13;לתקצוב&#13;(אש''ח)" Width="75" /> 
                            <telerik:GridViewDataColumn IsReadOnly="True" DataFormatString="{}{0:#,##0.00₪}" UniqueName="SumBudgetRequest" Header="שריון &#13;לפעילויות&#13;(אש''ח)" Width="75"/>  
                            <telerik:GridViewDataColumn IsReadOnly="True" DataFormatString="{}{0:#,##0.00₪}" UniqueName="SumOrderAllocation" Header="התחייבות&#13;לפעילויות&#13;(אש''ח)" Width="75" /> 
                            <telerik:GridViewDataColumn IsReadOnly="True" DataFormatString="{}{0:#,##0.00₪}" UniqueName="SumOrderPaid" Header="שולם&#13;בפועל&#13;(אש''ח)"  Width="75"/>  
                            <telerik:GridViewDataColumn IsReadOnly="True" DataFormatString="{}{0:#,##0.00₪}" UniqueName="BalanceToPay" Header="יתרה&#13;לתשלום&#13;(אש''ח)" Width="75"/>  
                            <telerik:GridViewDataColumn IsReadOnly="True" DataFormatString="{}{0:#,##0.00₪}" UniqueName="ActivityTypeName" Header="סוג&#13;פעילות" Width="120"/>  
                        </telerik:RadGridView.Columns> 
                        <telerik:RadGridView.HierarchyChildTemplate> 
                            <DataTemplate>                            
                                    <telerik:RadGridView Name="gvBudget" Loaded="OnChildGridLoaded" 
                                                         CanUserReorderColumns="False"  HorizontalContentAlignment="Right" 
                                                         CanUserFreezeColumns="False" ShowGroupPanel="False" AutoGenerateColumns="False" 
                                                         FlowDirection="RightToLeft" IsFilteringAllowed="False" ShowColumnHeaders="False" CellEditEnded="gvBudget_CellEditEnded">  
                                        <telerik:RadGridView.Columns> 
                                                <telerik:GridViewDataColumn IsReadOnly="True" UniqueName="aa" Header="סוג תקציב"  Width="33"/>  
                                                <telerik:GridViewDataColumn IsReadOnly="True" UniqueName="Name" Header="שם חשבון"  Width="160"  CellStyle="{StaticResource ToolTipColumnStyle}"/>  
                                                <telerik:GridViewDataColumn IsReadOnly="True" UniqueName="DisplayNum" Header="מספר חשבון"  Width="110"/>  
                                                <telerik:GridViewDataColumn DataFormatString="{}{0:#,##0.00₪}" IsReadOnly="True" UniqueName="TotalBudget" Header="הקצבה כוללת &#13;אש''ח"  Width="75"/>  
                                                <telerik:GridViewDataColumn DataFormatString="{}{0:#,##0.00₪}" IsReadOnly="True" UniqueName="BalanceBudgetAllocation" Header="יתרה&#13;לתקצוב&#13;אש''ח" Width="75" /> 
                                                <telerik:GridViewDataColumn DataFormatString="{}{0:#,##0.00₪}" IsReadOnly="True" UniqueName="SumBudgetRequest" Header="שריון &#13;לפעילות&#13;אש''ח" Width="75"/>  
                                                <telerik:GridViewDataColumn DataFormatString="{}{0:#,##0.00₪}" IsReadOnly="True" UniqueName="SumOrderAllocation" Header="התחיבות&#13;לפעילות&#13;אש''ח" Width="75" /> 
                                                <telerik:GridViewDataColumn DataFormatString="{}{0:#,##0.00₪}" IsReadOnly="True" UniqueName="SumOrderPaid" Header="שולם&#13;בפועל"  Width="75"/>  
                                                <telerik:GridViewDataColumn DataFormatString="{}{0:#,##0.00₪}" IsReadOnly="True" UniqueName="BalanceToPay" Header="יתרה&#13;לתשלום" Width="75"/>  
                                                <telerik:GridViewComboBoxColumn UniqueName="ActivityTypeID" DataMemberBinding="{Binding ActivityTypeID}" DisplayMemberPath="Name" SelectedValueMemberPath="Id" Header="סוג&#13;פעילות" Width="120"  /> 
                                        </telerik:RadGridView.Columns> 
                                        <telerik:RadGridView.HierarchyChildTemplate> 
                                            <DataTemplate> 
                                                    <telerik:RadGridView Name="gvSubBudget" Loaded="OnSubChildGridLoaded" CellEditEnded="gvBudget_CellEditEnded" 
                                                         CanUserReorderColumns="False"  HorizontalContentAlignment="Right" 
                                                         CanUserFreezeColumns="False" ShowGroupPanel="False" AutoGenerateColumns="False" 
                                                         FlowDirection="RightToLeft" IsFilteringAllowed="False" ShowColumnHeaders="False">  
                                                    <telerik:RadGridView.Columns> 
                                                        <telerik:GridViewDataColumn IsReadOnly="True" UniqueName="aa" Header="סוג תקציב"  Width="32"/>  
                                                        <telerik:GridViewDataColumn IsReadOnly="True" UniqueName="Name" Header="שם חשבון"  Width="160"  CellStyle="{StaticResource ToolTipColumnStyle}"/>  
                                                        <telerik:GridViewDataColumn IsReadOnly="True" UniqueName="DisplayNum" Header="מספר חשבון"  Width="110"/>  
                                                        <telerik:GridViewDataColumn DataFormatString="{}{0:#,##0.00₪}" IsReadOnly="True" UniqueName="TotalBudget" Header="הקצבה כוללת &#13;אש''ח"  Width="75"/>  
                                                        <telerik:GridViewDataColumn DataFormatString="{}{0:#,##0.00₪}" IsReadOnly="True" UniqueName="BalanceBudgetAllocation" Header="יתרה&#13;לתקצוב&#13;אש''ח" Width="75" /> 
                                                        <telerik:GridViewDataColumn DataFormatString="{}{0:#,##0.00₪}" IsReadOnly="True" UniqueName="SumBudgetRequest" Header="שריון &#13;לפעילות&#13;אש''ח" Width="75"/>  
                                                        <telerik:GridViewDataColumn DataFormatString="{}{0:#,##0.00₪}" IsReadOnly="True" UniqueName="SumOrderAllocation" Header="התחיבות&#13;לפעילות&#13;אש''ח" Width="75" /> 
                                                        <telerik:GridViewDataColumn DataFormatString="{}{0:#,##0.00₪}" IsReadOnly="True" UniqueName="SumOrderPaid" Header="שולם&#13;בפועל"  Width="75"/>  
                                                        <telerik:GridViewDataColumn DataFormatString="{}{0:#,##0.00₪}" IsReadOnly="True" UniqueName="BalanceToPay" Header="יתרה&#13;לתשלום" Width="75"/>  
                                                        <telerik:GridViewComboBoxColumn UniqueName="ActivityTypeID" DataMemberBinding="{Binding ActivityTypeID}" DisplayMemberPath="Name" SelectedValueMemberPath="Id" Header="סוג&#13;פעילות" Width="120"/>  
                                                </telerik:RadGridView.Columns> 
                                                    </telerik:RadGridView>                                                  
                                            </DataTemplate> 
                                        </telerik:RadGridView.HierarchyChildTemplate> 
                                    </telerik:RadGridView>                               
                            </DataTemplate> 
                        </telerik:RadGridView.HierarchyChildTemplate>                      
                    </telerik:RadGridView>                     
                    </StackPanel> 
                </StackPanel> 
            </GroupBox> 

Thanks




7 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 14 Sep 2009, 08:39 AM
Hello Orit,

When the grid is inside ScrollViewer or StackPanel all rows will be created (no grid scrollbar). This is due to the fact that the grid is measured with infinity height.

Kind regards,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Orit
Top achievements
Rank 1
answered on 14 Sep 2009, 08:43 AM
so how can I fix it?
I do want to have scrolls
0
Vlad
Telerik team
answered on 14 Sep 2009, 08:44 AM
Hi Orit,

In this case you should not put the grid inside ScrollViewer or StackPanel.

Regards,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Orit
Top achievements
Rank 1
answered on 14 Sep 2009, 08:47 AM
I put the grid inside a StackPanel
cause I need to add a StackPanel.Resources
for the tooltip
any idea?? 
0
Stefano Zambonin
Top achievements
Rank 1
answered on 15 Oct 2009, 07:22 AM
I have the same problem but in a normal Grid.

 

 

<Grid Grid.Row="1" Grid.Column="1">

 

 

 

 

<Grid.RowDefinitions>

 

 

 

<RowDefinition Height="Auto"/> ???? if i do not use Auto it works but i need it

 

 

 

<RowDefinition />

 

 

 

</Grid.RowDefinitions>

 

 

 

 

<Grid Grid.Row="0">

 

 

 

 

<Grid.RowDefinitions>

 

 

 

<RowDefinition Height="Auto"/>

 

 

 

<RowDefinition Height="Auto"/>

 

 

 

<RowDefinition/>

 

 

 

</Grid.RowDefinitions>

 

 

 

<local:gdfxBBoxRecTypeFilter x:Name="BBRTFilter" Grid.Row="0"/>

 

 

 

<local:gdfxBBoxRecInfo x:Name="BBRInfo" Grid.Row="1"/>

 

 

 

<telerik:RadGridView x:Name="RGVBBoxRecords" Grid.Row="2" CanUserReorderColumns="False" CanUserSortColumns="False" CanUserInsertRows="False" CanUserFreezeColumns="False" ShowGroupPanel="False" BorderThickness="0"/>

 

 

 

 

</Grid>
.......

 

0
Hristo
Telerik team
answered on 16 Oct 2009, 06:48 AM
Hi Stefano Zambonin,

Grid panel with RowDefinition Height=Auto is measuring this content with Infinity. This is why the scroll viewer is not showing. You should modify your xaml and place RadGridView in a row that is with Fixed or Star height if you want scroll viewer and virtualization to work.

Best wishes,
Hristo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Stefano Zambonin
Top achievements
Rank 1
answered on 16 Oct 2009, 07:23 AM
Thank you for your answer.
Effectively yesterday i discovered it and used the definition for the two rows like:

<RowDefinition Height="1*"/>
<RowDefinition Height="0*"/>

to obtain the needed result.

Thank you anyway.
Tags
GridView
Asked by
Orit
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Orit
Top achievements
Rank 1
Stefano Zambonin
Top achievements
Rank 1
Hristo
Telerik team
Share this question
or