question

Terrence7-3576 avatar image
0 Votes"
Terrence7-3576 asked JessieZhang-2116 answered

VS Tabbed template NewItemPage...Background black, but no style to set it??

File new project, Xamarin.Forms, Tabbed project.

Look at NewItemPage.xaml. The background is black, but I can't tell what is styling it that way.

 <?xml version="1.0" encoding="UTF-8"?>
 <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
              xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
              x:Class="App1Tabbed.Views.NewItemPage"
              Shell.PresentationMode="ModalAnimated"
              Title="New Item">
    
     <ContentPage.Content>
         <StackLayout Spacing="3" Padding="15">
             <Label Text="Text" FontSize="Medium" />
             <Entry Text="{Binding Text, Mode=TwoWay}" FontSize="Medium" />
             <Label Text="Description" FontSize="Medium" />
             <Editor Text="{Binding Description, Mode=TwoWay}" AutoSize="TextChanges" FontSize="Medium" Margin="0" />
             <StackLayout Orientation="Horizontal">
                 <Button Text="Cancel" Command="{Binding CancelCommand}" HorizontalOptions="FillAndExpand"></Button>
                 <Button Text="Save" Command="{Binding SaveCommand}" HorizontalOptions="FillAndExpand"></Button>
             </StackLayout>
         </StackLayout>
     </ContentPage.Content>
        
 </ContentPage>
dotnet-xamarin
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

JessieZhang-2116 avatar image
0 Votes"
JessieZhang-2116 answered

Hello,


Welcome to our Microsoft Q&A platform!

According to your step , I did a test, the default background color of my page (including NewItemPage) is white.

I used the latest version of nuget xamarin forms and visual studio ide.

If you want to change the style of page, you can define our style in file App.xaml and AppShell.xaml.

For example, the default code of App.xaml is as follows, and we can define out style as we want :

 <Application.Resources>
     <ResourceDictionary>
         <Color x:Key="Primary">#2196F3</Color>
         <Style TargetType="Button">
             <Setter Property="TextColor" Value="White"></Setter>
             <Setter Property="VisualStateManager.VisualStateGroups">
                 <VisualStateGroupList>
                     <VisualStateGroup x:Name="CommonStates">
                         <VisualState x:Name="Normal">
                             <VisualState.Setters>
                                 <Setter Property="BackgroundColor" Value="{StaticResource Primary}" />
                             </VisualState.Setters>
                         </VisualState>
                         <VisualState x:Name="Disabled">
                             <VisualState.Setters>
                                 <Setter Property="BackgroundColor" Value="#332196F3" />
                             </VisualState.Setters>
                         </VisualState>
                     </VisualStateGroup>
                 </VisualStateGroupList>
             </Setter>
         </Style>
     </ResourceDictionary>        
 </Application.Resources>


Best Regards,

Jessie Zhang


If the response is helpful, please click "Accept Answer" and upvote it.


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.






5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.