Wednesday, March 22, 2017

mvvm double click event in listview


If you want to get the double click event on a listview item you can try with this code;



  <ListView Grid.Row="0"  
                Grid.RowSpan="3"  
                Grid.Column="0"  
                Width="250"  
                Height="200"  
                HorizontalAlignment="Stretch"  
                VerticalAlignment="Top"  
                AlternationCount="2"  
                BorderBrush="#FFA8CC7B"  
                ItemContainerStyle="{StaticResource alternatingStyle}"  
                ItemsSource="{Binding FromPayerNameList}"  
                SelectedItem="{Binding SelectedFromPayer, Mode=TwoWay}">  
             <ListView.ItemTemplate>  
               <DataTemplate>  
                 <TextBlock Width="{Binding Path=ActualWidth, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListView}}}" Text="{Binding cpayername}">  
                   <TextBlock.InputBindings>  
                     <MouseBinding Command="{Binding DataContext.PrayerSingleLeftToRightMove, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" CommandParameter="{Binding .}" MouseAction="LeftDoubleClick" />  
                   </TextBlock.InputBindings>  
                 </TextBlock>  
               </DataTemplate>  
             </ListView.ItemTemplate>  
           </ListView>  


If you want to multiple text binding on listview you can try this:

   <ListView Grid.Row="0"  
                Grid.RowSpan="3"  
                Grid.Column="0"  
                Width="300"  
                Height="200"  
                HorizontalAlignment="Stretch"  
                VerticalAlignment="Top"  
                AlternationCount="2"  
                BorderBrush="#FFA8CC7B"  
                ItemContainerStyle="{StaticResource alternatingStyle}"  
                ItemsSource="{Binding FromBinNameList}"  
                SelectedItem="{Binding SelectedFromBin, Mode=TwoWay}">  
             <ListView.ItemTemplate>  
               <DataTemplate>  
                 <TextBlock Width="{Binding Path=ActualWidth, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListView}}}">  
                   <TextBlock.Text>  
                     <MultiBinding StringFormat="{}{0} | {1}">  
                       <Binding Path="cbinno" />  
                       <Binding Path="cinsplanname" />  
                     </MultiBinding>  
                   </TextBlock.Text>  
                   <TextBlock.InputBindings>  
                     <MouseBinding Command="{Binding DataContext.BinSingleLeftToRightMove, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" CommandParameter="{Binding .}" MouseAction="LeftDoubleClick" />  
                   </TextBlock.InputBindings>  
                 </TextBlock>  
               </DataTemplate>  
             </ListView.ItemTemplate>  
           </ListView>  

Ensure that this project has Microsoft.Bcl.Build installed and packages.config is located next to the project file

In my Xamarin form application their was dependency Restclient on Microsoft.Bcl.Build Microsoft.Bcl. i just remove all using nuget and ...