2016-11-22 46 views
0

我有名單在XAML頁面:禁用亮點

<ListView x:Name="ListTypeView" ItemsSource="{Binding ResourceType}" BackgroundColor="#FFFFFF" HeightRequest="210" WidthRequest="300" HorizontalOptions="CenterAndExpand" RowHeight="30"> 
    <ListView.ItemTemplate> 
     <DataTemplate> 
      <ViewCell> 
       <StackLayout StyleId="Settings_StackLayout" Orientation="Horizontal" Padding="0" Margin="50,0,0,0"> 
        <Label FontSize="Medium" HorizontalOptions="StartAndExpand" Text="{Binding ResourceType}" TextColor="Black" VerticalOptions="Center" WidthRequest="100"></Label> 
        <Image x:Name="Image" Source="{Binding Checkbox}" HorizontalOptions="StartAndExpand" WidthRequest="18" HeightRequest="18"> 
         <Image.GestureRecognizers> 
          <TapGestureRecognizer Command="{Binding Source={x:Reference ListTypeView}, Path=BindingContext.ListTypeChangeCommand}" CommandParameter="{Binding .}"/> 
         </Image.GestureRecognizers> 
        </Image> 
       </StackLayout> 
      </ViewCell> 
     </DataTemplate> 
    </ListView.ItemTemplate> 
</ListView> 

我想在ListView中點擊 禁用亮點(刪除列表選擇是藍色的顏色默認)

回答

0

如果您在圖像上定義了TapGestureRecognizer,那麼如果您點擊圖像,則不應選擇列表項目。如果您希望禁用的項目抽頭選擇,那麼你需要使用不同的事件 - 列表項抽頭

lstItems.ItemTapped += LstItems_ItemTapped; 

然後

private void LstItems_ItemTapped(object sender, ItemTappedEventArgs e) 
     { 
      //do whatever you need with selected item and reset it 
      ((ListView)sender).SelectedItem = null; 
     }