【问题标题】:Xamarin Forms Can Draw ContentPage On ContentPage?Xamarin 表单可以在 ContentPage 上绘制 ContentPage?
【发布时间】:2021-11-16 10:39:17
【问题描述】:

enter image description here

我想在 ContentPage 上绘制其他 ContentPage 像亲子关系。

Xamarin 可以吗?

【问题讨论】:

  • 没有。您可以在 ContentPage 中显示 ContentView。
  • 感谢回复。很抱歉,如何在 ContentPage 中绘制 ContentView?

标签: xamarin xamarin.forms


【解决方案1】:

如何在 ContentPage 中绘制 ContentView?

从文档Xamarin.Forms ContentView可以知道:

Xamarin.Forms ContentView 类是一种布局类型,它包含 单个子元素,通常用于创建自定义, 可重复使用的控件。 ContentView 类继承自 TemplatedView。

ContentView 类定义了一个属性:

内容是一个View 对象。此属性由BindableProperty 对象支持,因此它可以成为数据绑定的目标。 ContentView 还继承了 TemplatedView 类的属性:

ControlTemplate 是一个ControlTemplate,可以定义或覆盖控件的外观。

ContentView 类可用于创建自定义控件。

创建自定义控件的过程是:

  1. 在 Visual Studio 中使用 ContentView 模板创建一个新类 2019 年。
  2. 在代码隐藏文件中定义任何独特的属性或事件 新的自定义控件。
  3. 为自定义控件创建 UI。

更多详情可以查看:https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/layouts/contentview

上面的文档中还包含一个示例,您可以在这里查看:https://docs.microsoft.com/en-us/samples/xamarin/xamarin-forms-samples/userinterface-contentviewdemos/

【讨论】:

  • 感谢您的回答。我可以在 ControlPage 上绘制 Controlview。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-02-07
  • 1970-01-01
  • 2018-01-07
  • 1970-01-01
  • 2015-07-24
  • 1970-01-01
相关资源
最近更新 更多