I had no issues creating a frame in C# markup and it's been displaying just fine before now.
I tried to set the BorderColor property to dynamically change with the app theme using frame.SetAppThemeColor(Frame.BorderColor, Colors.White, Colors.Black)
.
public class ExampleFrame : ContentView
{
public ExampleFrame()
{
Frame frame = new Frame
{
BackgroundColor = Colors.Transparent,
CornerRadius = 0,
Margin = 0
};
frame.SetAppThemeColor(Frame.BorderColor, Colors.LightGray, Colors.White);
Content = frame;
}
}
This gives me the following error under Frame.BorderColor
:
'Rect' does not contain a definition for 'BorderColor' and no accessible extension method 'BorderColor' accepting a first argument of type 'Rect' could be found (are you missing a using directive or an assembly reference?)
I assume I have the wrong property but I'm not sure what the right one would be since BorderBrush
also produces the same error.
Please change the following code:
frame.SetAppThemeColor(Frame.BorderColor, Colors.LightGray, Colors.White);
to
frame.SetAppThemeColor(Microsoft.Maui.Controls.Frame.BorderColorProperty, Colors.LightGray, Colors.White);
In addition, the official document about the Frame in the .net maui 8.0 said:
The Frame class existed in Xamarin.Forms and is present in .NET MAUI for users who are migrating their apps from Xamarin.Forms to .NET MAUI. If you're building a new .NET MAUI app it's recommended to use Border instead, and to set shadows using the Shadow bindable property on VisualElement.