Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

How to Change the MenuItem Colors of ViewList in iOS ViewCellRenderer ?

$
0
0

Is there any way to Change the color of ContextAction Menus added in Xamarin.Forms Xaml file.

IsDestructive="True" sets the menu color to Red. But i need another menu to look like Green or some other color.

<ListView x:Name="planList" ItemsSource="{x:Static local:SampleData.PLAN_DATA}" RowHeight="150" HorizontalOptions="FillAndExpand">
    <ListView.ItemTemplate>
        <DataTemplate>
            <ViewCell>
                <ViewCell.ContextActions>
                    <MenuItem Clicked="OnEditClick" Text="Edit" CommandParameter="{Binding .}"/> <!-- THIS HAS TO BE GREEN COLOR -->
                    <MenuItem Clicked="OnDeleteClick" Text="Delete" IsDestructive="True" />
                </ViewCell.ContextActions>
                <ViewCell.View>
                    <StackLayout Orientation="Vertical"  HorizontalOptions="Start" VerticalOptions="FillAndExpand">
                        <!--Non Editable State-->
                        <StackLayout Orientation="Horizontal" Spacing="28" IsVisible="{Binding isNotSaveState}">
                            <Frame  WidthRequest="130" HeightRequest="50" BackgroundColor="#151617" HorizontalOptions="Start">
                                <Label Text="{Binding from}" TextColor="#ff9600" FontSize="Medium" FontFamily="Helvetica"/>
                            </Frame>
                        </StackLayout>
                        <!--Editable State-->
                        <StackLayout Orientation="Horizontal" Spacing="0"  IsVisible="{Binding isSaveState}">
                            <StackLayout Orientation="Horizontal" Spacing="5">
                                <Label Text="From" TextColor="#838288"  FontSize="Medium" FontFamily="Helvetica"/>
                                <Entry Text="" BackgroundColor="Red"/>
                            </StackLayout>
                            <Button Text="Save" BackgroundColor="Green" CommandParameter="{Binding .}" Clicked="onSaveClick" />
                        </StackLayout>
                    </StackLayout>
                </ViewCell.View>
            </ViewCell>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>

Here is my Renderer.

[assembly: ExportRenderer(typeof(MyApp.Views.Cells.CustomViewCell), typeof(MyApp.iOS.Views.Cells.CustomViewCellRenderer))]
namespace MyApp.iOS.Views.Cells
{

    public class CustomViewCellRenderer : ViewCellRenderer
    {
        public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv)
        {
            UITableViewCell cell = base.GetCell(item, reusableCell, tv);

            // I have no Idea how to access the Swipe Menus from Renderer

            //cell.EditingAccessory
            //cell.EditingAccessoryView

            return cell;
        }        
    }
}

Thanks in Advance.


Viewing all articles
Browse latest Browse all 91519

Trending Articles