2013-07-24 2 views
3

У меня странная проблема с xaml. Visual studio для wp говорит мне, что xaml недействителен, но когда я выполняю приложение, он отлично работает.Этот Xaml недействителен ... Я не понимаю, почему

<phone:PhoneApplicationPage 
    x:Class="Friends_And_Money.ContList" 
    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" 
    xmlns:local="clr-namespace:Friends_And_Money"  
    FontFamily="{StaticResource PhoneFontFamilyNormal}" 
    FontSize="{StaticResource PhoneFontSizeNormal}" 
    Foreground="{StaticResource PhoneForegroundBrush}" 
    SupportedOrientations="Portrait" Orientation="Portrait" 
    mc:Ignorable="d" 
    shell:SystemTray.IsVisible="True"> 

    <!--LayoutRoot è la griglia radice in cui viene inserito tutto il contenuto della pagina--> 
    <phone:PhoneApplicationPage.Resources> 
     <local:ContactPictureConverter x:Key="ImageConverter" /> 
     <DataTemplate x:Key="AddrBookGroupHeaderTemplate"> 
      <Border Background="Transparent" Padding="5"> 
       <Border Background="{StaticResource PhoneAccentBrush}" BorderBrush="{StaticResource PhoneAccentBrush}" BorderThickness="2" Width="62" 
     Height="62" Margin="0,0,18,0" HorizontalAlignment="Left"> 
        <TextBlock Text="{Binding Key}" Foreground="{StaticResource PhoneForegroundBrush}" FontSize="48" Padding="6" 
      FontFamily="{StaticResource PhoneFontFamilySemiLight}" HorizontalAlignment="Left" VerticalAlignment="Center"/> 
       </Border> 
      </Border> 
     </DataTemplate> 
     <phone:JumpListItemBackgroundConverter x:Key="BackgroundConverter"/> 
     <phone:JumpListItemForegroundConverter x:Key="ForegroundConverter"/> 
     <Style x:Key="AddrBookJumpListStyle" TargetType="phone:LongListSelector"> 
      <Setter Property="GridCellSize" Value="113,113"/> 
      <Setter Property="LayoutMode" Value="Grid" /> 
      <Setter Property="ItemTemplate"> 
       <Setter.Value> 
        <DataTemplate> 
         <Border Background="{Binding Converter={StaticResource BackgroundConverter}}" Width="113" Height="113" Margin="6" > 
          <TextBlock Text="{Binding Key}" FontFamily="{StaticResource PhoneFontFamilySemiBold}" FontSize="48" Padding="6" 
          Foreground="{Binding Converter={StaticResource ForegroundConverter}}" VerticalAlignment="Center"/> 
         </Border> 
        </DataTemplate> 
       </Setter.Value> 
      </Setter> 
     </Style> 



     <DataTemplate x:Key="AddrBookItemTemplate">   
      <StackPanel VerticalAlignment="Top" Margin="0,5,0,5"> 
       <Grid> 
        <Grid.ColumnDefinitions> 
         <ColumnDefinition Width="5" ></ColumnDefinition> 
         <ColumnDefinition Width="auto" ></ColumnDefinition> 
         <ColumnDefinition Width="5" ></ColumnDefinition> 
         <ColumnDefinition Width="auto" ></ColumnDefinition> 
        </Grid.ColumnDefinitions> 
        <Image Source="{Binding Photo, Converter={StaticResource ImageConverter}}" Grid.Column="1" Width="62" Height="62" Stretch="Fill" /> 
        <TextBlock Grid.Column="3" FontWeight="Light" FontSize="40" Text="{Binding FirstName}" /> 
       </Grid> 
      </StackPanel> 
     </DataTemplate> 



    </phone:PhoneApplicationPage.Resources> 

    <Grid x:Name="LayoutRoot" Background="Transparent"> 


     <Grid.RowDefinitions> 
       <RowDefinition Height="Auto"/> 
       <RowDefinition Height="*"/> 
     </Grid.RowDefinitions> 

     <!--TitlePanel contiene il nome dell'applicazione e il titolo della pagina--> 
     <StackPanel Grid.Row="0" Margin="12,17,0,28"> 
      <TextBlock Text="{Binding Path=LocalizedResources.ApplicationTitle, Source={StaticResource LocalizedStrings}}" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,0"/> 
      <TextBlock Text="{Binding Path=LocalizedResources.ContactTitle, Source={StaticResource LocalizedStrings}}" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/> 
     </StackPanel> 

     <!--ContentPanel - inserire ulteriore contenuto qui--> 
     <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> 
      <phone:LongListSelector x:Name="LongList" 
            Background="Transparent" 
            GroupHeaderTemplate="{StaticResource AddrBookGroupHeaderTemplate}" 
            ItemTemplate="{StaticResource AddrBookItemTemplate}" 
            JumpListStyle="{StaticResource AddrBookJumpListStyle}" 
            LayoutMode="List" 
            IsGroupingEnabled="true" 
            HideEmptyGroups ="true" /> 
     </Grid> 
    </Grid> 
</phone:PhoneApplicationPage> 

Я следовал учебник (с разницей в longlistselector) отсюда: [http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh286418(v=vs .105) .aspx] [1]

Как я могу сказать, все работает отлично, longlistselector покажет мне изображения и имя контакта.

Struct показать:

namespace Friends_And_Money 
{ 
    class ContactStruct 
    { 
     public string FirstName 
     { 
      get; 
      set; 
     } 

     public WriteableBitmap Photo 
     { 
      get; 
      set; 
     } 

     public ContactStruct(string name, WriteableBitmap photo) 
     { 
      this.FirstName = name; 
      this.Photo = photo; 
     } 

    } 
} 

Благодаря каждому, что поможет.

Новые данные: Ошибка заключена в datatemplate AddrBookItemTemplate, и я заметил, что если я оставлю атрибут источника изображения, ошибка исчезнет. Кажется, что-то с привязкой.

ответ

3

Visual studio for wp сообщит мне, что xaml недействителен, но когда я выполняю приложение, он отлично работает.

Прошу игнорировать конструктора. Это довольно капризно.

+0

Для начала, спасибо за ваш ответ. Это мой первый подход с wp, и это началось с этого странного пути. Нет никакого риска, что они откажутся от моего приложения для этого сообщения «xaml not valid»? –

+0

Дизайнер вообще не отражает реальность. –

2

Возможно, это плохая копия/вставка, но ваш первый элемент (<phone:PhoneApplicationPage>) не близко.

+0

Вы правы, я сделал плохую копию/вставку. –

Смежные вопросы