我下课了:
  
   public class TitlePropertyViewModel : BaseViewModel
    {
        private int _propertyId;
        private string _name;
        private bool _isRequired;
        private bool _isChecked;
        private bool _answerIsChecked;
        public string GroupingParameter { get; set; }
        public int PropertyId { get => _propertyId; set { _propertyId = value; OnPropertyChanged(); } }
        public string Name { get => _name; set { _name = value; OnPropertyChanged(); } }
        public bool IsChecked { get => _isChecked; set { _isChecked = value; OnPropertyChanged(); } }
        public bool AnswerIsChecked { get => _answerIsChecked; set { _answerIsChecked = value; OnPropertyChanged(); SelectedAnswerChanged?.Invoke(this, new EventArgs()); } }
        public bool IsRequired { get => _isRequired; set { _isRequired = value; OnPropertyChanged(); } }
        public override string ToString() => $"{this.Name}: {(this.IsChecked ? "Checked" : "-")} | {(this.IsRequired ? "Required" : "-")}";
    }
  
   我在视图模型中的属性是:
  
   private IList<TitlePropertyViewModel> _titleProperties;
    public IList<TitlePropertyViewModel> TitleProperties { get => _titleProperties; set { _titleProperties = value; OnPropertyChanged(); OnPropertyChanged(nameof(GrouppedTitleProperties)); OnPropertyChanged(nameof(GrouppedFilteredTitleProperties)); } }
    public object GrouppedTitleProperties { get => this.TitleProperties?.GroupBy(g => g.GroupingParameter); }
    public object GrouppedFilteredTitleProperties { get => this.TitleProperties?.Where(w => w.IsChecked || w.IsRequired).GroupBy(g => g.GroupingParameter); }
  
   我在titleproperties中添加数据,然后像这样在我的listview中绑定它:
  
   <ListView
                ItemsSource="{Binding GrouppedFilteredTitleProperties}"
                IsPullToRefreshEnabled="False"
                IsRefreshing="{Binding IsBusy}"
                IsGroupingEnabled="True"
                HasUnevenRows="True"
                SeparatorVisibility="None"
                CachingStrategy="RecycleElement"
                BackgroundColor="Transparent"
                ItemSelected="Item_Selected"
                >
                <ListView.GroupHeaderTemplate>
                    <DataTemplate>
                        <ViewCell>
                            <StackLayout Padding="25,15" BackgroundColor="{DynamicResource PrimaryColor}">
                                <Label Text="{Binding Key}" FontAttributes="Bold" FontSize="Large" 
                                       HorizontalOptions="Start" 
                                       VerticalOptions="Center"
                                       TextColor="{DynamicResource TextColorLight}" />
                            </StackLayout>
                        </ViewCell>
                    </DataTemplate>
                </ListView.GroupHeaderTemplate>
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell>
                            <StackLayout Orientation="Horizontal" Margin="25,5">
                                <renderer:IconView WidthRequest="25" Source="{Binding IsChecked,Converter={StaticResource PositiveIconConverter}}" FillColor="{Binding IsChecked,Converter={StaticResource PositiveColorConverter}}" VerticalOptions="CenterAndExpand" />
                                <Label Text="{Binding Name}" TextColor="{DynamicResource TextColorLight}"/>
                                <Image Source="exclamation_sign.png" IsVisible="{Binding IsRequired}" VerticalOptions="CenterAndExpand" />
                            </StackLayout>
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
  
   这在调试模式下工作,但当我设置发布模式时,它不会在GroupHeaderTemplate中同时显示密钥iOS和Android。但当我在标签上设置静态文本时,它就工作了。
  
  
   这是调试模式:
   
     
   
  
  
  
  
   这是释放模式:
   
    