maui
maui copied to clipboard
Style is not replaced
Description
I'm trying to change a style via binding, unfortunately it only works once.
The first style sets a RadialGradientBrush, the second style reverses this and it doesn't work.
The button keeps the style even if I set the stzle to null
Steps to Reproduce
1.Create Maui App 1.Create 2 Styles
Style 1
var onStyle = new Style(typeof(Border));
//ON Style
var gradienStopsON = new GradientStopCollection()
{
new GradientStop(Color.FromArgb("#f8f8f8"),0.3f),
new GradientStop(Color.FromArgb("#f5f7f8"),0.5f),
new GradientStop(Color.FromArgb("#e8eef7"),0.8f),
new GradientStop(Color.FromArgb("#dee9f6"),1.0f)
};
var radialGradient = new RadialGradientBrush(gradienStopsON);
radialGradient.Center = new Point(0.48f, 0.58f);
onStyle.Setters.Add(new Setter
{
Property = Border.BackgroundProperty,
Value = radialGradient
});
return onStyle;
Style 2
var offStyle = new Style(typeof(Border));
//Off Style
var shadow = new Shadow();
shadow.Brush = new SolidColorBrush(Color.FromArgb("#0473f1"));
shadow.Opacity = 0.20f;
shadow.Radius = 18;
shadow.Offset = new Point(0, 4);
offStyle.Setters.Add(new Setter
{
Property = Border.ShadowProperty,
Value = shadow
});
offStyle.Setters.Add(new Setter
{
Property = Border.BackgroundProperty,
Value = new SolidColorBrush(Colors.White)
});
return offStyle;
- Create a Border
<Border
BackgroundColor="White"
HeightRequest="40"
Stroke="White"
StrokeThickness="0"
Style="{Binding Style}"
WidthRequest="40">
<Image
Aspect="Center"
HorizontalOptions="Center"
Source="{Binding IconName}"
VerticalOptions="Center" />
<Border.StrokeShape>
<EllipseGeometry
Center="20,20"
RadiusX="20"
RadiusY="20" />
</Border.StrokeShape>
</Border>
- Change Style
[ObservableProperty]
public Style style;
Style = onStyle;

iOS

As you can see here the RadialGradientBrush is applied but you can't go back
Version with bug
6.0 (current)
Last version that worked well
Unknown/Other
Affected platforms
Android, I was not able test on other platforms
Affected platform versions
Android 11
Did you find any workaround?
No response
Relevant log output
No response
Hello, it is currently not possible to change styles. This variant also does not work https://github.com/dotnet/maui/issues/7585 this is really a blocker
repro with vs main build(32627.411) on Android emulator(work well on windows)
Hello can someone help me here? is there any way i can fix this temporarily? On iOS it works without problems
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.