Xaml 带有UWP刷新的Xamarin表单会导致值消失

Xaml 带有UWP刷新的Xamarin表单会导致值消失,xaml,xamarin,uwp,xamarin.forms,xamarin.forms.listview,Xaml,Xamarin,Uwp,Xamarin.forms,Xamarin.forms.listview,我有一个使用Android和UWP的Xamarin表单应用程序。在Android下一切都很好,但在UWP下,当我想修改屏幕上显示的一些值时,我遇到了一个问题 这是我的(简化的)视图模型(使用Fody.PropertyChanged): 以及显示SaleModel的列表的(部分)XAML <ListView x:Name="ListView" ItemsSource="{Binding Sales, Mode=TwoWay}" SelectedItem="{Binding SelectedS

我有一个使用Android和UWP的Xamarin表单应用程序。在Android下一切都很好,但在UWP下,当我想修改屏幕上显示的一些值时,我遇到了一个问题

这是我的(简化的)视图模型(使用Fody.PropertyChanged):

以及显示SaleModel的列表的(部分)XAML

<ListView x:Name="ListView" ItemsSource="{Binding Sales, Mode=TwoWay}" SelectedItem="{Binding SelectedSale, Mode=TwoWay}">   
<ListView.ItemTemplate>
  <DataTemplate>
    <ViewCell>
      <ViewCell.View>
        <Grid>
          <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
          </Grid.ColumnDefinitions>

          <Image Grid.Column="0" Source="arrow.png">
            <Image.GestureRecognizers>
              <TapGestureRecognizer Command="{Binding Path=BindingContext.AddQuantityCommand, Source={x:Reference Name=SalesPage}}" CommandParameter="{Binding .}" />
            </Image.GestureRecognizers>
          </Image>

          <Label Grid.Column="1" Text="{Binding Quantity, Mode=OneWay}" 
        </Grid>
      </ViewCell.View>
     </ViewCell>
    </DataTemplate>
   </ListView.ItemTemplate>
 </ListView>


我已经测试了你的代码并复制了你的问题。我写了下面的
ViewCell
替换你的。请尝试修改您的
ViewCell

<ViewCell>
    <StackLayout BackgroundColor="#eee"
    Orientation="Vertical">
        <StackLayout Orientation="Horizontal">
            <Image Source="time.jpg" HeightRequest="50" WidthRequest="50" >
                <Image.GestureRecognizers>
                    <TapGestureRecognizer Command="{Binding AddQuantityCommand} " CommandParameter="{Binding .}"/>
                </Image.GestureRecognizers>
            </Image>
            <Label Text="{Binding Quantity}"
            TextColor="#f35e20" />
            <Label Text="{Binding Quantity}"
            HorizontalOptions="EndAndExpand"
            TextColor="#503026" />
        </StackLayout>
    </StackLayout>
</ViewCell>


我已经上传到github了。请参阅。

我必须保留网格,因为我的列远不止2个值。但是你用StackLayout(垂直方向)环绕的解决方案解决了我的问题。谢谢!
<ListView x:Name="ListView" ItemsSource="{Binding Sales, Mode=TwoWay}" SelectedItem="{Binding SelectedSale, Mode=TwoWay}">   
<ListView.ItemTemplate>
  <DataTemplate>
    <ViewCell>
      <ViewCell.View>
        <Grid>
          <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
          </Grid.ColumnDefinitions>

          <Image Grid.Column="0" Source="arrow.png">
            <Image.GestureRecognizers>
              <TapGestureRecognizer Command="{Binding Path=BindingContext.AddQuantityCommand, Source={x:Reference Name=SalesPage}}" CommandParameter="{Binding .}" />
            </Image.GestureRecognizers>
          </Image>

          <Label Grid.Column="1" Text="{Binding Quantity, Mode=OneWay}" 
        </Grid>
      </ViewCell.View>
     </ViewCell>
    </DataTemplate>
   </ListView.ItemTemplate>
 </ListView>
<ViewCell>
    <StackLayout BackgroundColor="#eee"
    Orientation="Vertical">
        <StackLayout Orientation="Horizontal">
            <Image Source="time.jpg" HeightRequest="50" WidthRequest="50" >
                <Image.GestureRecognizers>
                    <TapGestureRecognizer Command="{Binding AddQuantityCommand} " CommandParameter="{Binding .}"/>
                </Image.GestureRecognizers>
            </Image>
            <Label Text="{Binding Quantity}"
            TextColor="#f35e20" />
            <Label Text="{Binding Quantity}"
            HorizontalOptions="EndAndExpand"
            TextColor="#503026" />
        </StackLayout>
    </StackLayout>
</ViewCell>