Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

ContextAction Command from custom ViewCell

$
0
0

I have a custom ViewCell which gets selected by a Tempalte Selector.
Now i want that the Command from the ContextAction is executed in the corresponding page ViewModel,
but i don't now how to get the reference to MyPageName.

This is my custom ViewCell:

<?xml version="1.0" encoding="UTF-8"?>
<ViewCell xmlns="http://xamarin.com/schemas/2014/forms" 
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
          xmlns:local="clr-namespace:MyApplication.Converters;assembly=MyApplication"
             x:Class="MyApplication.Pages.Custom.CustomCell">
    <ViewCell.ContextActions>
                                <MenuItem 
                                    Command="{Binding Path=BindingContext.OnSettingsCommand, Source={x:Reference Name=MyPageName}}"
                                    CommandParameter="{Binding .}"
                                    Icon="settings_white.png"
                                    Text="More"/>
                                <MenuItem 
                                    Command="{Binding Path=BindingContext.OnDeleteCommand, Source={x:Reference Name=MyPageName}}" 
                                    CommandParameter="{Binding .}"
                                    Icon="delete.png"
                                    IsDestructive="True"
                                    Text="Delete"/>
                            </ViewCell.ContextActions>
    <ViewCell.View>
        <StackLayout 
                                Orientation="Horizontal" 
                                Padding="10"
                                Spacing="10">
            <StackLayout.Resources>
                <ResourceDictionary>
                    <local:DateConverter x:Key="dateConverter"/>
                </ResourceDictionary>
            </StackLayout.Resources>
            <Image Source="{Binding Image}" />
            <StackLayout Orientation="Vertical" HorizontalOptions="StartAndExpand"
                                             VerticalOptions="Center">
                <Label 
                                            Text="{Binding Title}"  
                                            TextColor="{StaticResource Dark}"
                                            VerticalOptions="End"
                                            Font="Medium, Bold"/>

                <Label 
                                            Text="{Binding CreationDate, Converter={StaticResource dateConverter}}"  
                                            TextColor="{StaticResource grayDark}" 
                                            FontSize="Small" />
            </StackLayout>
            <StackLayout Orientation="Vertical" VerticalOptions="Center">
                <Image Source="{Binding ImageConnectionTypeStatus}"/>
                <Image Source="{Binding ImageSignalStrength}"/>
            </StackLayout>
            <Image Source="arrow_right.png"/>
        </StackLayout>
    </ViewCell.View>
</ViewCell>

Does anybody have an idea ?


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>