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.
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.
- Frame.BorderColorProperty not Frame.BorderColor. – Stephen Quan Commented Nov 22, 2024 at 8:22
- 2 Do not use frame. – H.A.H. Commented Nov 22, 2024 at 9:18
- @H.A.H. is right. Frame docs says: The Frame control is marked as obsolete in .NET MAUI 9, and will be completely removed in a future release. The Border control should be used in its place. For more information see Border. – Stephen Quan Commented Nov 22, 2024 at 10:20
1 Answer
Reset to default 0Please 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 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.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742293732a4416695.html
评论列表(0条)