Hello,
You have a Grid that wraps the frame, but you didn't set BackgroundColor
for it. Please bind a BGColor
and set the BackgroundColor
of Frame
to "#e4e4e4"
.
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<Grid BackgroundColor="{Binding BGColor}">
<Frame
HasShadow="False"
Padding="8"
CornerRadius="{OnIdiom Phone=20, Tablet=30}"
BorderColor="#bdbdbd"
Margin="5"
BackgroundColor="#e4e4e4">
<StackLayout
VerticalOptions="FillAndExpand"
Margin="5,0,5,0"
Orientation="Horizontal">
Also, you should set different BGColor
in Light Mode and Dark Mode, and you don't have to set the homelistview.BackgroundColor
.
Please refer to the following code:
private void SetMode()
{
try
{
mode = Preferences.Default.Get("mode", "light");
if (mode == "light")
{
LightMode();
SetHomePageOptions();
}
else if (mode == "dark")
{
DarkMode();
SetDarkHomePageOptions();//set different PageOptions according to Mode
}
}
catch (Exception e)
{
...
}
}
private void LightMode()
{
home_layout.BackgroundColor = Colors.White;
// homelistview.BackgroundColor = Colors.White;
}
private void DarkMode()
{
home_layout.BackgroundColor = Color.FromArgb("#434343");
// homelistview.BackgroundColor = Color.FromArgb("#434343");
}
private void SetHomePageOptions()
{
homeList.Clear();
homeList.Add(new HomeResponse() { Title = "Option 1", BGColor = Colors.White, TextColor = Colors.Black, ImageSource = "ic_black_right_arrow_xx.png" });
...
//Color.FromArgb("#e4e4e4")
homelistview.ItemsSource = homeList;
}
private void SetDarkHomePageOptions()
{
homeList.Clear();
homeList.Add(new HomeResponse() { Title = "Option 1", BGColor = Color.FromArgb("#434343"), TextColor = Colors.Black, ImageSource = "ic_black_right_arrow_xx.png" });
...
homelistview.ItemsSource = homeList;
}
Best Regards,
Wenyan Zhang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.