2017-05-09 15 views
1

私はリストビューとボタンでグリッドを持つxamlを持っていて、 エラー:指定されたキャストは無効です。 このエラーをコンパイルする瞬間が表示されます。エラー:指定されたキャストは無効です。 Xaml

私はこの問題は、グリッド内にあるリストビューであってもよいと思うが、私は本当にこれが私のXAMLで解決

を見つけることができませんでした:

<?xml version="1.0" encoding="utf-8"?> 
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="FCR.App.Views.AdvanceSearchResultPage" Title="AdvanceSearchResultPage" xmlns:extended="clr-namespace:FCR.App.ExtendedClasses;assembly=FCR.App"> 
    <ContentPage.Padding> 
     <OnPlatform x:TypeArguments="Thickness" iOS="0, 10, 0, 0" WinPhone="20,20,20,20" /> 
    </ContentPage.Padding> 
    <ContentPage.Content> 
     <StackLayout VerticalOptions="StartAndExpand"> 
      <ContentView IsVisible="false" x:Name="TitleHC"> 
       <Grid> 
        <Grid.ColumnDefinitions> 
         <ColumnDefinition Width="0.5*" /> 
         <ColumnDefinition Width="9.5*" /> 
        </Grid.ColumnDefinitions> 
        <Grid.RowDefinitions> 
         <RowDefinition Height="Auto" /> 
        </Grid.RowDefinitions> 
        <Image Source="blue_circle.png" Grid.Column="0" /> 
        <StackLayout Padding="0,4,0,5" VerticalOptions="Fill" Grid.Column="1"> 
         <Label VerticalOptions="CenterAndExpand" TextColor="#0368b1" Text="Histórico de conéxiones" FontSize="20"> 
          <Label.FontFamily> 
           <OnPlatform x:TypeArguments="x:String"> 
            <OnPlatform.iOS>FrutigerLTStd-Cn</OnPlatform.iOS> 
            <OnPlatform.Android>FrutigerLTStd-Cn.otf#FrutigerLTStd-Cn</OnPlatform.Android> 
           </OnPlatform> 
          </Label.FontFamily> 
         </Label> 
        </StackLayout> 
       </Grid> 
      </ContentView> 
      <ContentView IsVisible="false" x:Name="TitleHM"> 
       <Grid> 
        <Grid.ColumnDefinitions> 
         <ColumnDefinition Width="0.5*" /> 
         <ColumnDefinition Width="9.5*" /> 
        </Grid.ColumnDefinitions> 
        <Grid.RowDefinitions> 
         <RowDefinition Height="Auto" /> 
        </Grid.RowDefinitions> 
        <Image Source="blue_circle.png" Grid.Column="0" /> 
        <StackLayout Padding="0,4,0,5" VerticalOptions="Fill" Grid.Column="1"> 
         <Label VerticalOptions="CenterAndExpand" TextColor="#0368b1" Text="Histórico de módificaciones" FontSize="20"> 
          <Label.FontFamily> 
           <OnPlatform x:TypeArguments="x:String"> 
            <OnPlatform.iOS>FrutigerLTStd-Cn</OnPlatform.iOS> 
            <OnPlatform.Android>FrutigerLTStd-Cn.otf#FrutigerLTStd-Cn</OnPlatform.Android> 
           </OnPlatform> 
          </Label.FontFamily> 
         </Label> 
        </StackLayout> 
       </Grid> 
      </ContentView> 
      <Grid VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand"> 
       <Grid.RowDefinitions> 
        <RowDefinition Height="Auto" /> 
        <RowDefinition Height="*" /> 
       </Grid.RowDefinitions> 
       <ContentView x:Name="contentListView" IsVisible="true" Padding="0,10,0,0" BackgroundColor="White" Grid.Row="0"> 
        <ListView x:Name="resultListView" BackgroundColor="White" HasUnevenRows="true" HorizontalOptions="FillAndExpand" SeparatorVisibility="None"> 
         <ListView.ItemTemplate> 
          <DataTemplate> 
           <ViewCell> 
            <ViewCell.View> 
             <StackLayout BackgroundColor="White" Padding="0" Opacity="90"> 
              <ContentView Padding="1,0,1,1" BackgroundColor="Gray"> 
               <Grid 
                BackgroundColor="White"> 
                <Grid.ColumnDefinitions> 
                 <ColumnDefinition Width="0.7*"> 
                 </ColumnDefinition> 
                 <ColumnDefinition Width="0.15*"> 
                 </ColumnDefinition> 
                 <ColumnDefinition Width="0.15*"> 
                 </ColumnDefinition> 
                </Grid.ColumnDefinitions> 
                <StackLayout Grid.Column="0"> 
                 <Label Margin="-5" Text="{Binding NombreCompleto}" TextColor="Gray" Font="Bold,13" /> 
                 <Label Margin="-5" 
                  Text="{Binding OrganizacionMayusculas}" TextColor="Gray" FontSize="13" /> 
                 <Label Margin="-5" Text="{Binding Region}" TextColor="Gray" FontSize="13" /> 
                </StackLayout> 
                <Label Margin="0,0,0,2" Text="Detalle" Grid.Column="1" 
                 Font="Bold, 13" ClassId="{Binding IdContacto}" TextColor="Gray" VerticalOptions="End"> 
                 <Label.FontFamily> 
                  <OnPlatform x:TypeArguments="x:String" iOS="8"> 
                   <OnPlatform.iOS>FrutigerLTStd-BoldCn</OnPlatform.iOS> 
                   <OnPlatform.Android>FrutigerLTStd-BoldCn.otf#FrutigerLTStd-BoldCn</OnPlatform.Android> 
                  </OnPlatform> 
                 </Label.FontFamily> 
                 <Label.GestureRecognizers> 
                  <TapGestureRecognizer Tapped="OnTapGestureRecognizerDetail" /> 
                 </Label.GestureRecognizers> 
                </Label> 
                <Label Margin="0,0,0,2" Text="Borrar" Grid.Column="2" 
                 Font="Bold, 13" ClassId="{Binding IdContacto}" TextColor="Gray" VerticalOptions="End"> 
                 <Label.FontFamily> 
                  <OnPlatform x:TypeArguments="x:String" iOS="8"> 
                   <OnPlatform.iOS>FrutigerLTStd-BoldCn</OnPlatform.iOS> 
                   <OnPlatform.Android>FrutigerLTStd-BoldCn.otf#FrutigerLTStd-BoldCn</OnPlatform.Android> 
                  </OnPlatform> 
                 </Label.FontFamily> 
                 <Label.GestureRecognizers> 
                  <TapGestureRecognizer Tapped="OnTapGestureRecognizerDelete" /> 
                 </Label.GestureRecognizers> 
                </Label> 
               </Grid> 
              </ContentView> 
             </StackLayout> 
            </ViewCell.View> 
           </ViewCell> 
          </DataTemplate> 
         </ListView.ItemTemplate> 
        </ListView> 
       </ContentView> 
       <StackLayout> 
        <extended:CustomButton Text="Volver" Grid.Row="1" x:Name="dismissbutton" Clicked="OnDismissButtonClicked" WidthRequest="100" Style="{StaticResource buttonStyle}" /> 
       </StackLayout> 
      </Grid> 
     </StackLayout> 
    </ContentPage.Content> 
</ContentPage> 
+0

メッセージの内容は何ですか?それは通常、何から何をしようとしているかへのキャストを言います。この情報だけに基づいて言うのは難しいです。 –

答えて

0

問題

  1. 一般的に、これらの種類のエラーはデータバインディングの作業中に発生する可能性があります。私たちはいくつかのコントロールで異なるタイプをバインドしようとしていますが、コンパイラは正確には期待していません。 ClassId="{Binding IdContacto}"

    私はあなたが正しくないか、結合されているかどうかわからない -

は、私は奇妙な結合はほとんど見つけることができるいくつかの場所があります。私があなたの場合は、すべてのClassIdバインディングを削除してから、そのプロセスのコンパイルビルドに進みます。

  1. また、私はOnPlatformコードをコメントアウトし、プロジェクトをビルド/コンパイル/実行しようとします。

これはあなたが試してみることができるいくつかの長いショットです。 Stacktrace全体を見てから、正確な問題をより詳細に診断することができます。

関連する問題