TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Venkata Swamy Balaraju
NA
3.9k
924.3k
How to change BG color for ContextActions in Xamarin.Forms
Sep 13 2018 2:42 AM
Hi guys,
Hope your doing great,
I created ListView with three Context Actions, here I want to set different background color for each MenuItem like below
xml
version
=
"1.0"
encoding
=
"UTF-8"
?>
<
ViewCell
xmlns
=
"http://xamarin.com/schemas/2014/forms"
xmlns:x
=
"http://schemas.microsoft.com/winfx/2009/xaml"
x:Class
=
"PureSale.Core.Views.OrdersListTemplate"
>
<
Grid
Padding
=
"10"
>
<
Grid.ColumnDefinitions
>
<
ColumnDefinition
Width
=
"*"
/>
<
ColumnDefinition
Width
=
"Auto"
/>
Grid.ColumnDefinitions
>
<
StackLayout
Spacing
=
"5"
>
<
Label
Text
=
"{Binding Title}"
FontAttributes
=
"Bold"
HorizontalOptions
=
"StartAndExpand"
/>
<
Label
Text
=
"{Binding StartDate}"
HorizontalOptions
=
"StartAndExpand"
/>
StackLayout
>
<
Image
Source
=
"indicatorIconBlack.png"
Grid.Column
=
"1"
HorizontalOptions
=
"EndAndExpand"
VerticalOptions
=
"CenterAndExpand"
/>
Grid
>
ViewCell
>
public
partial
class
OrdersListTemplate : ViewCell {
public
OrdersListTemplate(){
InitializeComponent();
var deleteAction =
new
MenuItem { Text =
"Delete"
, StyleId =
"labelRedStyle"
};
deleteAction.SetBinding(MenuItem.CommandParameterProperty,
new
Binding(
"."
));
deleteAction.Clicked += (sender, e) => {
};
var archiveAction =
new
MenuItem { Text =
"Archive"
, IsDestructive =
true
};
archiveAction.SetBinding(MenuItem.CommandParameterProperty,
new
Binding(
"."
));
archiveAction.Clicked += (sender, e) => {
};
var cancelAction =
new
MenuItem { Text =
"Cancel"
};
cancelAction.SetBinding(MenuItem.CommandParameterProperty,
new
Binding(
"."
));
cancelAction.Clicked += (sender, e) => {
};
ContextActions.Add(cancelAction);
ContextActions.Add(archiveAction);
ContextActions.Add(deleteAction);
}
}
XAML:
<
ListView
HasUnevenRows
=
"true"
ItemsSource
=
"{Binding OrderItems}"
ios:ListView.SeparatorStyle
=
"FullWidth"
SelectedItem
=
"{Binding SelectedListItem}"
>
<
ListView.ItemTemplate
>
<
DataTemplate
>
<
views:PartyListTemplate
/>
DataTemplate
>
ListView.ItemTemplate
>
ListView
>
How can I set StyledId for menu item, Please suggest me
Thanks in advance
Reply
Answers (
1
)
missing xml comment for publicly visible type or member web
XML document structures must start and end within the same