0
votes
<StackPanel Orientation="Horizontal" Margin="10,43,0,0">
            <RichTextBlock x:Name="MYRTB" HorizontalAlignment="Center" VerticalAlignment="Top" Foreground="#FFEE0000" UseLayoutRounding="True">
                <Paragraph Foreground="#FFFD0000">
                    <Run Text="Testtest"/>
                </Paragraph>
            </RichTextBlock>
            <ListView x:Name="MyListViewNr1">
                <ListViewItem Content="ListView Entry 1"/>
                <ListViewItem Content="ListView Entry 2"/>
                <ListViewItem Content="ListView Entry 2888"/>
            </ListView>
        </StackPanel>

I am trying to make this StackPanel fill the screen of my WinRT app. I'm already using the "automatic" property for width and height, but when I add a Listview Entry or a Paragraph to the RichTextBlock that is long enough then the text will just go outside of the screen.

If I use Vertical Orientation for the StackPanel the WIDTH is automatically adjusted but not the height, what means if there are enought listview entries they will just go "under" the screen.

Is there actually a way to do this via XAML or do I need to do this via Code (using C# here). If so, how can I access the CURRENT width/height of my app, since I want to make it automatically resize for different resolutions as well as orientation (landscape/portrait).

Thank you in advance!

2
You may want to consider wrapping your StackPanel in a ScrollViewer so that your content doesn't go "under" the screen as you describe it.K Mehta
Try replacing the StackPanel with a Grid with two rows in Grid.RowDefinitions. Put the RichTextBlock in Grid.Row="0" and the Listview in Grid.Row="1". That would look better, controls will expand autmatically.kiewic
Kiewic's solution worked. A simple Grid with Width="*" did the job. Thank you both (Sorry for my bad english btw, I am not a native speaker)GenericUser123
@Kiewic post it as an answer so GenericUser123 can accept itFactor Mystic

2 Answers

0
votes

Use Grid instead of StackPanel

<Grid Margin="10,43,0,0">
            <RichTextBlock x:Name="MYRTB" HorizontalAlignment="Center"   VerticalAlignment="Top" Foreground="#FFEE0000" UseLayoutRounding="True">
                <Paragraph Foreground="#FFFD0000">
                    <Run Text="Testtest"/>
                </Paragraph>
            </RichTextBlock>
            <ListView x:Name="MyListViewNr1">
                <ListViewItem Content="ListView Entry 1"/>
                <ListViewItem Content="ListView Entry 2"/>
                <ListViewItem Content="ListView Entry 2888"/>
            </ListView>
  </Grid>

try this.