UserControl for cross-platform Xamarin Forms(跨平台 Xamarin 表单的 UserControl)
问题描述
我一直在寻找很长一段时间,但仍然没有找到一种方法来为跨平台 Xamarin 表单创建像 UserControls 这样的 WPF.这甚至可以做到吗?我在 Visual Studio 2013 中使用 Xamarin.
I have been looking for a long time now but still haven't found a way to create WPF like UserControls for cross-platform Xamarin Forms. Can this even be done? I am using Xamarin with Visual Studio 2013.
推荐答案
这是一个 XAML 示例.只是添加你可以有任何基本的视觉元素.例如.Grid、StackLayout、Image 等.
Here is a XAML example. Just to add you can have any base visual element. E.g. a Grid, StackLayout, Image etc.
<Grid xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Mobile.Control.UserControl">
</Grid>
下面是代码
namespace Mobile.Control
{
public partial class UserControl : Grid
{
public UserControl()
{
InitializeComponent();
}
}
}
要使用它,请转到您的页面并实现命名空间
To use it, go to your page and implement the namespace
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:control="clr-namespace:Mobile.Control;assembly=Mobile"
x:Class="Mobile.View.MyPage">
然后在页面中
<control:UserControl />
这篇关于跨平台 Xamarin 表单的 UserControl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:跨平台 Xamarin 表单的 UserControl


- C#MongoDB使用Builders查找派生对象 2022-09-04
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- 输入按键事件处理程序 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01