0
<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!

  • 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 Aug 17 '13 at 19:55
  • 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 Aug 17 '13 at 20:01
  • 1
    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 Aug 17 '13 at 20:24
  • @Kiewic post it as an answer so GenericUser123 can accept it – Factor Mystic Jun 28 '14 at 18:45

2 Answers2

0

If you need have something like hub (Content control for complex layout) for windows 8 you should use GridView with different item templates. example: http://blogs.msdn.com/b/synergist/archive/2012/09/25/windows-store-app-xaml-gridview-with-variable-templates.aspx

Community
  • 1
  • 1
Alexei Malashkevich
  • 1,575
  • 1
  • 17
  • 34
0

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.

Nemi Chand
  • 138
  • 1
  • 10