我已经寻找了很长时间,但仍然没有找到一种方法来为跨平台 Xamarin Forms 创建像 UserControls 这样的 WPF。这还可以吗?我将 Xamarin 与 Visual Studio 2013 结合使用。
这是一个 XAML 示例。只需添加您就可以拥有任何基本视觉元素。例如。网格、StackLayout、图像等。
<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();
}
}
}
要使用它,请转到您的页面并实施名称空间
<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 />
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)