2017-05-18 7 views
1

奇妙な問題がありますか?これはXamarinのフォーム(UWP)でのみ発生しています。リストビュー内でリストビューを使用しています。各リストをクリックすると、子リストが表示されます。また、スクロールできるように、子リストの固定高さを設定しました。今すぐチェックすると、黒い色がより多くのアイテムを持っています。どのように私はこれを修正することができます。一覧については残りのスペースに黒い色が入っています。リストビューxamarin-UWP

Descr

XAML:

<ListView x:Name="MyProducts" 
      IsRefreshing="{Binding IsBusy, Mode=TwoWay}" 
      RefreshCommand="{Binding GetAllProducts,Mode=TwoWay}" 
      IsPullToRefreshEnabled="true" 
      HasUnevenRows="True" 
      BackgroundColor="White" 
      ItemSelected="CategorySelected" 
      SeparatorVisibility="None" 
      ItemsSource="{Binding MyProductsList}"> 
    <ListView.ItemTemplate> 
     <DataTemplate> 
      <ViewCell> 
       <StackLayout BackgroundColor="#e6e6e6" Margin="0,2,0,2"> 
        <StackLayout Margin="1" BackgroundColor="White"> 
         <Grid Padding="0,10,0,0"> 
          <Grid.RowDefinitions> 
           <RowDefinition Height="Auto"/> 
           <RowDefinition Height="Auto"/> 
           <RowDefinition Height="Auto"/> 
          </Grid.RowDefinitions> 
          <Grid.ColumnDefinitions> 
           <ColumnDefinition Width="9*"/> 
           <ColumnDefinition Width="1*"/> 
          </Grid.ColumnDefinitions> 
          <Label Grid.Row="0" Grid.Column="0" Text="Product Category" YAlign="Center" Margin="10,0,0,0" Style="{DynamicResource LabelLightStyle}"/> 
          <Label Grid.Row="1" Grid.Column="0" Text="{Binding Model.ProductCategoryName}" Style="{DynamicResource LabelRedStyle}" YAlign="Center" Margin="10,0,0,0"/> 
          <Image Grid.Row="0" Grid.Column="1" IsVisible="{Binding IconDown}" Source="ArrowDown.png" HeightRequest="15" Grid.RowSpan="2" Margin="0,0,5,0" HorizontalOptions="End" VerticalOptions="Center"/> 
          <Image Grid.Row="0" Grid.Column="1" IsVisible="{Binding IconUp}" Source="ArrowUp.png" HeightRequest="15" Grid.RowSpan="2" Margin="0,0,5,0" HorizontalOptions="End" VerticalOptions="Center"/> 
          <ListView Grid.Row="2" Grid.ColumnSpan="2" 
             IsVisible="{Binding ListVisibility}" 
             SeparatorVisibility="Default" 
             SeparatorColor="#e6e6e6" 
             ItemSelected="ProductSelected" 
             HeightRequest="220" 
             BackgroundColor="#f2f2f2" 
             HorizontalOptions="FillAndExpand" 
             ItemsSource="{Binding Model.Products}"> 
           <ListView.ItemTemplate> 
            <DataTemplate> 
             <ViewCell> 
              <StackLayout BackgroundColor="#e6e6e6"> 
               <StackLayout Margin="0,0,0,1" BackgroundColor="#f2f2f2"> 
                <Grid Padding="0,10,0,10"> 
                 <Grid.RowDefinitions> 
                  <RowDefinition Height="Auto"/> 
                  <RowDefinition Height="Auto"/> 
                 </Grid.RowDefinitions> 
                 <Grid.ColumnDefinitions> 
                  <ColumnDefinition Width="9*"/> 
                  <ColumnDefinition Width="1*"/> 
                 </Grid.ColumnDefinitions> 
                 <Label Grid.Row="0" Grid.Column="0" Text="{Binding MachineModel, StringFormat='Machine Model Number : {0}'}" YAlign="Center" Margin="10,0,0,0" Style="{DynamicResource LabelStyle}"/> 
                 <Label Grid.Row="1" Grid.Column="0" Text="{Binding CreatedDate, StringFormat='Date {0}'}" Style="{DynamicResource LabelTinyStyle}" YAlign="Center" Margin="10,0,0,0"/> 
                 <Image Grid.Row="0" Grid.Column="1" Source="ArrowRight.png" HeightRequest="15" Grid.RowSpan="2" Margin="0,0,10,0" HorizontalOptions="End" VerticalOptions="Center"/> 
                </Grid> 
               </StackLayout> 
              </StackLayout> 
             </ViewCell> 
            </DataTemplate> 
           </ListView.ItemTemplate> 
          </ListView> 
         </Grid> 
        </StackLayout> 
       </StackLayout> 
      </ViewCell> 
     </DataTemplate> 
    </ListView.ItemTemplate> 
</ListView> 
+0

XAMLはどこですか?投稿できますか? – AVK

+0

これはIOSとAndroidで正常に動作しています。この問題はUWPでのみ発生しています。使用されているxamlを見つけてください。https://docs.google.com/document/d/1MpbGpZxfu6dsynLGGwJ_eYAHW1pnt37hHFVs1P6MrDM/edit?usp=sharing – Renjith

+0

なぜ、 'BackgroundColor ="#e6e6e6 "'で 'DataTemplate'に2つの' StackLayout'を持っていますか?もう一つは 'BackgroundColor =" White "'? – AVK

答えて

0

は、カスタムViewCellを書き込むことによって、ネイティブのDataTemplateを使用することによって、問題を修正しました。今すぐ高速スクロールで黒いセルはありません。誰かが役に立つと思うように私は自分の答えを投稿しています。例えばのために

:あなたは以下に表示される名前のリストがある場合:

 <ListView 
     ItemsSource="{Binding Products}"> 
     <ListView.ItemTemplate> 
      <DataTemplate> 
       <custom:CustomViewCell Name="{Binding Name}"/> 
      </DataTemplate> 
     </ListView.ItemTemplate> 
     </ListView> 
を:

まず、次のように

public class CustomViewCell : ViewCell 
    { 
    public static readonly BindableProperty NameProperty = 
     BindableProperty.Create("Name", typeof(string), typeof(CustomViewCell), ""); 

    public string Name 
    { 
     get { return (string)GetValue(NameProperty); } 
     set { SetValue(NameProperty, value); } 
    } 

    } 

今すぐXAMLでListViewコントロールを追加し、次のようにカスタムviewcell追加

次に、次のように、UWPプロジェクトのApp.xamlにDateTemplateスタイルを記述する必要があります。

<ResourceDictionary> 
    <DataTemplate x:Key="CustomTemplate"> 
     <Grid Padding="10"> 
      <TextBlock Foreground="#333333" FontSize="14" VerticalAlignment="Center" Text="{Binding Name"/> 
     </Grid> 
    </DataTemplate> 
    </ResourceDictionary> 

最後に、ネイティブのViewcellをListViewに置き換えるためにCustomRendererを記述します。

public class CustomViewCellRenderer : ViewCellRenderer 
{ 
public override Windows.UI.Xaml.DataTemplate GetTemplate(Cell cell) 
{ 
    return App.Current.Resources["CustomTemplate"] as Windows.UI.Xaml.DataTemplate; 
} 
} 

現在、リストは黒セルのレンダリングの問題なしで完全に機能します。

関連する問題