.NET MAUI Border 和 Frame 的区别
Difference between .NET MAUI Border and Frame
.NET MAUI 中的边框和框架在功能上有什么区别?
根据documentation一个Border的总结是
The .NET Multi-platform App UI (.NET MAUI) Border is a container control that draws a border, background, or both, around another control. A Border can only contain one child object. If you want to put a border around multiple objects, wrap them in a container object such as a layout.
而一个Frame的总结如下
The .NET Multi-platform App UI (.NET MAUI) Frame class is used to wrap a view or layout with a border that can be configured with color, shadow, and other options. Frames can be used to create borders around controls but can also be used to create more complex UI.
听起来他们都对我做同样的事情:在另一个视图周围绘制边框(无论是布局还是单个控件都无所谓)。那么为什么会有两种不同的观点呢?我如何决定使用哪一个?
我认为这是由于 .NET MAUI 的历史。 Frame
是 Xamarin.Forms 中的控件。我不确定它是否曾经打算成为 the 控件来在某些东西周围放置边框,但是因为 if 是唯一可以长时间显示阴影和边框的控件,很多人将他们的控件包装在 Frame
.
中
但是,现在有了 .NET MAUI,就有机会修复一些历史技术债务。这就是为什么 Border
被引入的原因,它更加灵活。例如,使用 Border
可以为每个角指定一个单独的角半径。您可以给 Border
一个渐变,而不仅仅是纯色。
因此,从功能的角度来看,Border
有更多选择,并且可能会比 Frame
更长久,尽管没有迹象表明 Frame
会很快消失。
这里和那里可能有更多的小差异。仅凭直觉,我认为 Border
表现更好,但我没有数据支持。
希望这能让它更清楚一点。
.NET MAUI 中的边框和框架在功能上有什么区别?
根据documentation一个Border的总结是
The .NET Multi-platform App UI (.NET MAUI) Border is a container control that draws a border, background, or both, around another control. A Border can only contain one child object. If you want to put a border around multiple objects, wrap them in a container object such as a layout.
而一个Frame的总结如下
The .NET Multi-platform App UI (.NET MAUI) Frame class is used to wrap a view or layout with a border that can be configured with color, shadow, and other options. Frames can be used to create borders around controls but can also be used to create more complex UI.
听起来他们都对我做同样的事情:在另一个视图周围绘制边框(无论是布局还是单个控件都无所谓)。那么为什么会有两种不同的观点呢?我如何决定使用哪一个?
我认为这是由于 .NET MAUI 的历史。 Frame
是 Xamarin.Forms 中的控件。我不确定它是否曾经打算成为 the 控件来在某些东西周围放置边框,但是因为 if 是唯一可以长时间显示阴影和边框的控件,很多人将他们的控件包装在 Frame
.
但是,现在有了 .NET MAUI,就有机会修复一些历史技术债务。这就是为什么 Border
被引入的原因,它更加灵活。例如,使用 Border
可以为每个角指定一个单独的角半径。您可以给 Border
一个渐变,而不仅仅是纯色。
因此,从功能的角度来看,Border
有更多选择,并且可能会比 Frame
更长久,尽管没有迹象表明 Frame
会很快消失。
这里和那里可能有更多的小差异。仅凭直觉,我认为 Border
表现更好,但我没有数据支持。
希望这能让它更清楚一点。