We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Way to Have ListView.DragIndicatorView Not Visible if ListView DragStartMode Set to None?

I have a Listview that I toggle from DragStartMode.None to DragStartMode.OnDragIndicator in code behind depending on a UI click.

I can't see a straight forward way to have the DragIndicatorView IsVisable = false if the DragStartMode is set to None and IsVisible = true if the DragStartMode is set to OnDragIndicator.

Is there a simple way do this?  I can think of a way to do this by adding a field to my data like ShowDragIndicator and implimenting an IValueConverter.  But this seems complicated for what should be inherently part of the control. Or at least a property like DontShowIfDragStartModeNotOnDragIndicator.

Any suggestions appreciated.

3 Replies

SP Subburaj Pandian Veluchamy Syncfusion Team May 27, 2019 02:19 PM UTC

Hi Robert, 
 
Thank you for contacting Syncfusion support. 
  
We would like to inform, you can achieve your requirement simply by binding the DragStartMode property directly to DragIndicatorView like below instead binding viewModel property. You can change the visibility of the DragValueConverter based on the DragStartMode value. But using converter is the only option to change the value of indicator. We regret to inform you that we cannot option to provide the bool property in source as per your requirement though it can be achieved in sample itself. 
  
Please find the sample for your reference, 
  
  
[Xaml] 
     <listView:SfListView x:Name="listView"DragStartMode="None" 
                          ItemsSource="{Binding ContactItems}" 
                          ItemSpacing="0,0,5,0"> 
  
                <listView:SfListView.ItemTemplate> 
                    <DataTemplate> 
                        <ViewCell> 
                            <ViewCell.View> 
                              <Grid > 
                                 <listView:DragIndicatorView ListView="{x:ReferencelistView}" IsVisible="{Binding DragStartMode, Source={x:ReferencelistView},Converter={StaticResource dragValueConverter}}}"> 
                                   <Grid > 
                                       <Image Source="DragIndicator.png" /> 
                                   </Grid> 
                                 </listView:DragIndicatorView> 
                              </Grid> 
                            </ViewCell.View> 
                        </ViewCell> 
                    </DataTemplate> 
                </listView:SfListView.ItemTemplate> 
            </listView:SfListView> 
  
Converter 
public class DragValueConverter : IValueConverter 
{ 
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 
        { 
            var dragMode = (DragStartMode)value ; 
            if (dragMode == DragStartMode.OnHold || dragMode == DragStartMode.OnDragIndicator) 
                return true; 
            else 
                return false; 
        } 
  
        public object ConvertBack(object value, Type targetType, objectparameter, CultureInfo culture) 
        { 
            throw new NotImplementedException(); 
        } 
} 
  
Please let us know if you need any further assistance. 
 
Regards,
Subburaj Pandian V     
 



RO Robert May 27, 2019 04:30 PM UTC

That was what I needed. I thought I might need an IValueConverter.  But I wasn't sure how to address the listView control and property.  Your way lets me do it without creating an extra field in the DB. 

I do still think this is the way the DragIndicatorView should work natively, perhaps with a property like ShowDragIndicator = "OnDragIndicator" (default) or "Always" or "OnHold" or "OnHoldOrOnDragIndicator".  

Anyway, my opinion.

Thanks for the help.


SP Subburaj Pandian Veluchamy Syncfusion Team May 28, 2019 12:41 PM UTC

Hi Robert 
  
Thank you for your valuable suggestion.  
 
We are glad that the solution provided meets your requirement. We have already provided DragIndicator with IsVisibleproperty to change its visible state and it can be achieved at the application level itself. So, considering that separate API will not be a feasible requirement. However, based on the number of traffic on this requirement, we will consider it in the future. 
  
Regards,
Subburaj Pandian V 


Loader.
Up arrow icon