0
votes

This is what I want to reach: Create a grid, which is fit to phone's screen. Two controls in the grid, a header stackpanel and a pivot control which fills the remaining space in the screen. In the pivot control i want to display three other controls. A header stackpanel with its full height (always visible), a button container with its full height (always visible) and a scrollable listview between the previous two controls which fills the remaining space in pivot item. I tryed, but if I set the listview's height to star char, it fills the full remaining space after header, i cannot see the buttons below and the listview is not scrollable. When I set the listview height fe. to 200 it works as I accepted, buttons are visible below listview and listview is scrollable. But I dont want to set any hard coded height, so what should i do to reach this behaviour with dinamic height settings? I simplyfied my xaml as I could to give an example. This example is working as i want but I would like to replace the fixed height of listview (200) to something dinamically value (*) to display listview with maximum height and keep it as scrollable control:

<Grid x:Name="LayoutRoot">
    <Grid.ChildrenTransitions>
        <TransitionCollection>
            <EntranceThemeTransition/>
        </TransitionCollection>
    </Grid.ChildrenTransitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <StackPanel Grid.Row="0" Margin="19,0,0,0">
            <TextBlock x:Uid="Header" Name="pageTitle" Text="TITLE" Style="{ThemeResource TitleTextBlockStyle}" Margin="0,2,0,0" Width="243" />
        </StackPanel>

    <Pivot x:Name="myPivot" Grid.Row="1" Margin="-10,0,-10,0" x:FieldModifier="public">
        <PivotItem x:Name="pivot_item1">
            <PivotItem.Header>
                <Grid >
                    <TextBlock Text="Header1"/>
                </Grid>
            </PivotItem.Header>
            <StackPanel>
                <Grid x:Name="PivotRoot">
                    <Grid.ChildrenTransitions>
                        <TransitionCollection>
                            <EntranceThemeTransition/>
                        </TransitionCollection>
                    </Grid.ChildrenTransitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="200"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>

                    <StackPanel Grid.Row="0" Margin="19,0,0,0">
                        <TextBlock x:Uid="PivotHeader"  Text="PivotHeader" Margin="0,2,0,0" Width="243" />
                    </StackPanel>

                    <ListView x:Name="DataListView" Grid.Row="1"  Margin="10,10,10,0" VerticalAlignment="Top" HorizontalAlignment="Stretch" x:FieldModifier="public">
                    </ListView>


                    <StackPanel Grid.Row="2" Margin="19,0,0,0">
                        <TextBlock x:Uid="PivotButtons"  Text="PivotButtons" Margin="0,2,0,0" Width="243" />
                    </StackPanel>

                </Grid>

            </StackPanel>
        </PivotItem>
        <PivotItem x:Name="pivot_item2" >
            <PivotItem.Header>
                <Grid >
                    <TextBlock Text="Header2"/>
                </Grid>
            </PivotItem.Header>
            <StackPanel>
                <TextBlock Text="page2"></TextBlock>
            </StackPanel>
        </PivotItem>
    </Pivot>
</Grid
1
did you tried to set the listview inside a scrollbar?Riadh Ben Hassine
I tried ScrollViewer it didnt helps. I may made a mistake, can u give me an example?Developer Joe
<ScrollViewer VerticalScrollBarVisibility="Visible" Height="250" > <ListView /> </ScrollViewer>Riadh Ben Hassine
you should set the height of the scrollRiadh Ben Hassine
Ok, but its a constant value again (250), this behaviour was reached without scroll too. I want a scrollable listview, which height is automatically set to maximum available size. Fe.: Screen is 400 pixel height. If the sum height of other controls is 150, listview's height must be set to 250 dinamically. I can reach this behaviour with a grid by using 3 column definitions and set their height to: auto, * , auto. But it seems doesnt works in a pivot control.Developer Joe

1 Answers