2012-02-01 54 views
0

這是在我的項目我的XAML代碼,在此第i個顯示MainListBox然後根據用戶的選擇顯示ChatListBox。當用戶選擇聊天,然後我得到運行時Xaml解析異常。AG_E_PARSER_BAD_PROPERTY_VALUE(第7行;位置51)

這是我整個的XAML代碼...

<phone:PhoneApplicationPage 
x:Class="DocomoMessenger.View.Buddies" 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone" 
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone" 
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
FontFamily="{StaticResource PhoneFontFamilyNormal}" 
FontSize="{StaticResource PhoneFontSizeNormal}" 
Foreground="{StaticResource PhoneForegroundBrush}" 
SupportedOrientations="Portrait" Orientation="Portrait" 
mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480" 
shell:SystemTray.IsVisible="True" Loaded="PhoneApplicationPage_Loaded"> 

<!--LayoutRoot is the root grid where all page content is placed--> 
<Grid x:Name="LayoutRoot" Background="Transparent"> 
    <Grid.RowDefinitions> 
     <RowDefinition Height="126"/> 
     <RowDefinition Height="580*"/> 
     <RowDefinition Height="75"/> 
    </Grid.RowDefinitions> 

    <!--TitlePanel contains the name of the application and page title--> 
    <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="2,2,0,2"> 
     <ProgressBar Height="3" Name="waitprogess" Margin="0,2,0,0" /> 
     <TextBlock x:Name="txtload" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,5,12,0" /> 
     <TextBlock x:Name="PageTitle" Text="page name" Margin="1,0,0,0" Style="{StaticResource PhoneTextTitle1Style}" HorizontalAlignment="Center" /> 
    </StackPanel> 

    <!--ContentPanel - place additional content here--> 
    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="2,0,2,0"> 
     <Border BorderThickness="5" BorderBrush="DarkGray" CornerRadius="10" Name="buddyborder"> 
       <ListBox x:Name="MainListBox" > 
        <ListBox.ItemTemplate> 
         <DataTemplate> 
          <Grid Height="100" > 
           <Grid.ColumnDefinitions> 
            <ColumnDefinition Width="50"/> 
            <ColumnDefinition Width="*"/> 
            <ColumnDefinition Width="50"/> 
           </Grid.ColumnDefinitions> 
           <Image Grid.Column="0" Source="{Binding IM}" Stretch="Fill" Width="50" Height="50" VerticalAlignment="Center" HorizontalAlignment="Center" ></Image> 
           <StackPanel Margin="1,4,0,0" Grid.Column="1" x:Name="details" Height="100"> 
            <TextBlock Text="{Binding Name}" Style="{StaticResource PhoneTextNormalStyle}" Foreground="Brown" Padding="10"/> 
            <TextBlock Text="{Binding StatusMsg}" FontSize="{StaticResource PhoneFontSizeSmall}" TextWrapping="Wrap" Padding="10" /> 
           </StackPanel> 
           <Image Tag="{Binding Name}" Source="{Binding IMChat}" Grid.Column="2" Stretch="Uniform" Width="40" Height="40" VerticalAlignment="Center" HorizontalAlignment="Center" Name="imgchat" MouseLeftButtonUp="imgchat_MouseLeftButtonUp"></Image> 
           <Line Stretch="UniformToFill" Grid.ColumnSpan="3" Stroke="DarkGray" StrokeThickness="2" Margin="0,10,0,0" X1="10" Y1="10" Y2="10" VerticalAlignment="Bottom" /> 
          </Grid> 
         </DataTemplate> 
        </ListBox.ItemTemplate> 
       </ListBox> 
     </Border> 

     <ListBox x:Name="ChatListBox" Margin="2,2,0,0" Opacity="1" Visibility="Collapsed" > 
      <ListBox.ItemTemplate> 
       <DataTemplate> 
        <Grid Name="megrid" Margin="3,5,0,0"> 
         <Grid.RowDefinitions> 
          <RowDefinition Height="40*"/> 
          <RowDefinition Height="40"/> 
         </Grid.RowDefinitions> 
         <Grid.ColumnDefinitions> 
          <ColumnDefinition Width="{Binding FirstCol}"/> 
          <ColumnDefinition Width="20"/> 
          <ColumnDefinition Width="{Binding LastCol}"/> 
         </Grid.ColumnDefinitions> 

         <Image Name="imgbud" Source="{Binding IM}" Grid.Column="{Binding ImgCol}" Grid.Row="1" Stretch="Uniform" Width="50" Height="50"/> 
         <Rectangle Grid.RowSpan="2" RadiusY="20" RadiusX="20" Grid.Column="{Binding RectCol}" Fill="{Binding Bru}" /> 
         <TextBlock Text="{Binding Name}" Grid.Row="0" TextWrapping="Wrap" Grid.Column="{Binding RectCol}" Padding="10" /> 
         <TextBlock Text="{Binding Time}" Grid.Row="1" Grid.Column="{Binding RectCol}" Padding="10" /> 
         <Path Data="{Binding Obj}" Fill="{Binding Bru}" Margin="0,0,-5,0" HorizontalAlignment="{Binding HorAlig}" Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" /> 
        </Grid> 
       </DataTemplate> 
      </ListBox.ItemTemplate> 
     </ListBox> 

    </Grid> 

    <Grid x:Name="sendmsg" Height="75" VerticalAlignment="Bottom" Grid.Row="2" Visibility="Collapsed"> 
     <TextBox Name="txtmsg" Text="type" Padding="5" Opacity="0.8" MouseLeftButtonUp="txtmsg_MouseLeftButtonUp" Width="370" HorizontalAlignment="Left" /> 
     <Image Name="imgsend" Width="100" Height="46" Source="/DocomoMessenger;component/Themes/send.png" HorizontalAlignment="Right" Stretch="UniformToFill" Margin="0,12,4,17" MouseLeftButtonUp="imgsend_MouseLeftButtonUp"/> 
    </Grid> 
</Grid> 

<!--Sample code showing usage of ApplicationBar--> 
<!--<phone:PhoneApplicationPage.ApplicationBar> 
    <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True"> 
     <shell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="Button 1"/> 
     <shell:ApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="Button 2"/> 
     <shell:ApplicationBar.MenuItems> 
      <shell:ApplicationBarMenuItem Text="MenuItem 1"/> 
      <shell:ApplicationBarMenuItem Text="MenuItem 2"/> 
     </shell:ApplicationBar.MenuItems> 
    </shell:ApplicationBar> 
</phone:PhoneApplicationPage.ApplicationBar>--> 

當我運行這段代碼,我得到以下XamlParsinException錯誤

enter image description here

enter image description here

任何人幫助我。 在此先感謝 Pavan。

+0

您能點擊「查看詳情......」,並看看任何的InnerException? (他們可能會嵌套)只需將它們添加到您的問題。 – 2012-02-01 05:52:07

+0

您可以將XAML添加到網格之前的問題上嗎? – 2012-02-01 06:39:05

+0

嗨Erno,我在我的問題中發佈了整個Xaml代碼。 – Pavan 2012-02-01 06:52:20

回答

0

我不能針下來,這是一個幾乎通用的消息並沒有太多發言權。

這裏是我會做什麼:

  1. 註釋掉所有內容,所以你留下了<PhoneApplicationPage ...>
  2. 評論指出,依賴於XAML所有的C#代碼你只是註釋掉
  3. 確保應用程序編譯。
  4. 現在慢慢地,一步一步,早在加入XAML元素。直到找到問題的行。

4.如果太硬,你可以扭轉這一招;評論out一部分零件。

+0

ChatListBox的問題,但我不知道它在哪裏。所以幫助我 – Pavan 2012-02-01 07:19:59

+0

重複DataTemplate的過程並讓我們知道。 – 2012-02-01 09:27:53

+0

錯誤將GridLength綁定到 Pavan 2012-02-01 09:49:42

0

什麼在你的PhoneApplicationPage_Loaded方法是什麼?

從您的片段缺少結束標記

</phone:PhoneApplicationPage> 

除了上面我是能夠建立和WP7 7.1運行此。我確實不得不省略你的Loaded和MouseLeftButtonUp引用,因爲我沒有完整的代碼。

+0

不,我發現問題,即,我綁定({Binding FirstCol})列寬到ChatListBox。我使用「自動」解決了我的問題。無論如何,謝謝你的迴應。對不起我的英語 – Pavan 2012-02-22 09:37:36

相關問題