Open gimenezfrg opened 2 hours ago
Similar issue from here: https://discord.com/channels/1277612890668404798/1291021245722136669/1291033875694485598
All the Dialogs implementations uses Colors from color dictionary. I.E. Modal itself, uses SurfaceColor
,
If you already passed your app colors as ColorsOverride
property of StyleResource in your App.xaml
like below, you can customize it easily:
Check here for further information: https://enisn-projects.io/docs/en/uranium/latest/Getting-Started#existing-projects
After this operation, you can customize colors from Colors.xaml
file in your project.
<Color x:Key="Surface">red</Color>
<Color x:Key="SurfaceDark">blue</Color>
Modal will be Red at light theme and it'll be Blue at dark theme:
Light | Dark |
---|---|
Labels are using default label style from your application.
Button and any other input controls use Primary
and PrimaryDark
colors by default. Also colors has specific classes to customize easily such as Dialog.Button0
, Dialog.Button1
, etc according to their own indexes
<Style TargetType="Button" Class="Dialog.Button0" ApplyToDerivedTypes="True" CanCascade="True">
<Setter Property="TextColor" Value="Red" />
<Setter Property="CornerRadius" Value="30" />
<Setter Property="BorderWidth" Value="2" />
<Setter Property="BorderColor" Value="Red" />
</Style>
Result:
Thanks for replying, I couldn't access the Discord channel, it says NO TEXT CHANNELS.
About the example you gave, it's like I said, I don't have the Colors.xaml and Styles.xaml files in my project.
I created two theme files (LightTheme.xaml and DarkTheme.xaml) and defined the colors in them, and my App.xaml is the same as the example above, so I can't do this:
My style definitions are inside App.xaml
You can override colors directly from App.xaml without creating Colors.xaml
<m:StyleResource BasedOn="{x:Reference appStyles}">
<m:StyleResource.ColorsOverride>
<ResourceDictionary>
<Color x:Key="Primary">black</Color>
<Color x:Key="Surface">white</Color>
</ResourceDictionary>
</m:StyleResource.ColorsOverride>
</m:StyleResource>
<ResourceDictionary x:Name="overrideStyles" Source="Resources/Styles/Override.xaml" />
</ResourceDictionary.MergedDictionaries>
In the latest version, also factory methods are provided by option pattern.
You can configure something like that in MauiProgram.cs
builder.Services.Configure<DialogOptions>(options =>
{
options.GetBackdropColor = () => Color.FromRgba(0, 0, 0, 0.5);
options.GetDivider = () => new BoxView { BackgroundColor = Colors.LightGray, HeightRequest = 1 };
options.GetHeader = (title) => new Label { Text = title.ToUpper() };
});
In my app I don't have the Colors.xaml and Styles.xaml files, I have the LightTheme.xaml and DarkTheme.xaml files, in which I set the colors, and in my App.xaml I have this:
`
`
I'm not able to change the colors of the UraniumUI components, especially the Dialogs, can someone help me?