Advertisement
Guest User

MVVM ListBox Trouble

a guest
May 19th, 2013
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 4.58 KB | None | 0 0
  1. <phone:PhoneApplicationPage x:Class="MvvmLight5.MainPage"
  2.                            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3.                            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4.                            xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
  5.                            xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
  6.                            xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  7.                            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  8.                            xmlns:ignore="http://www.ignore.com"
  9.                            mc:Ignorable="d ignore"
  10.                            FontFamily="{StaticResource PhoneFontFamilyNormal}"
  11.                            FontSize="{StaticResource PhoneFontSizeNormal}"
  12.                            Foreground="{StaticResource PhoneForegroundBrush}"
  13.                            SupportedOrientations="Portrait"
  14.                            Orientation="Portrait"
  15.                            shell:SystemTray.IsVisible="True"
  16.                            DataContext="{Binding Main, Source={StaticResource Locator}}">
  17.  
  18.     <!--LayoutRoot is the root grid where all page content is placed-->
  19.     <Grid x:Name="LayoutRoot"
  20.          Background="Transparent">
  21.         <Grid.RowDefinitions>
  22.             <RowDefinition Height="Auto" />
  23.             <RowDefinition Height="*" />
  24.         </Grid.RowDefinitions>
  25.  
  26.         <!--TitlePanel contains the name of the application and page title-->
  27.         <StackPanel x:Name="TitlePanel"
  28.                    Grid.Row="0"
  29.                    Margin="12,17,0,28">
  30.             <TextBlock Text="MY APPLICATION"
  31.                       Style="{StaticResource PhoneTextNormalStyle}"
  32.                       Margin="12,0" />
  33.             <TextBlock Text="page name"
  34.                       Margin="9,-7,0,0"
  35.                       Style="{StaticResource PhoneTextTitle1Style}" />
  36.         </StackPanel>
  37.  
  38.         <!--ContentPanel - place additional content here-->
  39.         <Grid x:Name="ContentPanel"
  40.              Grid.Row="1"
  41.              Margin="12,0,12,0">
  42.             <TextBlock Text="{Binding theText}">
  43.                
  44.             </TextBlock>
  45.  
  46.             <ListBox x:Name="myListBox" HorizontalAlignment="Left" Height="100" ItemsSource="{Binding theList}"
  47.                 VerticalAlignment="Top" Width="200">
  48.                 <ListBox.ItemTemplate>
  49.                     <DataTemplate>
  50.                         <ItemsControl ItemsSource="{Binding theList}">
  51.                             <ItemsControl.ItemTemplate>
  52.                                 <DataTemplate>
  53.                                     <StackPanel Orientation="Horizontal" Width="auto">
  54.                                         <TextBlock Text="{Binding Path=Key}" />
  55.                                         <TextBlock Text="{Binding Path=Value}" />
  56.                                     </StackPanel>
  57.                                 </DataTemplate>
  58.                             </ItemsControl.ItemTemplate>
  59.                         </ItemsControl>
  60.                     </DataTemplate>
  61.                 </ListBox.ItemTemplate>
  62.             </ListBox>
  63.             <ListBox x:Name="myListBox2" HorizontalAlignment="Left" Height="100"  
  64.                 VerticalAlignment="Bottom" Width="200">
  65.                 <ListBox.ItemTemplate>
  66.                     <DataTemplate>
  67.                         <ItemsControl ItemsSource="{Binding}">
  68.                             <ItemsControl.ItemTemplate>
  69.                                 <DataTemplate>
  70.                                     <StackPanel Orientation="Horizontal" Width="auto">
  71.                                         <TextBlock Text="{Binding Path=Key}" />
  72.                                         <TextBlock Text="{Binding Path=Value}" />
  73.                                     </StackPanel>
  74.                                 </DataTemplate>
  75.                             </ItemsControl.ItemTemplate>
  76.                         </ItemsControl>
  77.                     </DataTemplate>
  78.                 </ListBox.ItemTemplate>
  79.             </ListBox>
  80.  
  81.  
  82.             <TextBlock Text="{Binding WelcomeTitle}"
  83.                       Style="{StaticResource PhoneTextNormalStyle}"
  84.                       HorizontalAlignment="Center"
  85.                       VerticalAlignment="Center"
  86.                       TextAlignment="Center"
  87.                       TextWrapping="Wrap"
  88.                       FontSize="40" />
  89.  
  90.         </Grid>
  91.     </Grid>
  92.  
  93. </phone:PhoneApplicationPage>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement