将MAUI-C#控件转换为xaml-string

bvn4nwqk  于 2023-04-03  发布在  C#
关注(0)|答案(1)|浏览(136)

我知道我可以从xaml代码加载控件,如下所示:

string navigationButtonXAML = "<Button Text=\"Navigate\" />";
Button navigationButton = new Button().LoadFromXaml(navigationButtonXAML);

但是是否可以将我的C#控件转换为xaml,最终它应该看起来像这样:

string myControl = new MyControl.WriteToXAML();
oprakyz7

oprakyz71#

但是是否可以将我的C#控件转换为xaml,最终它应该看起来像这样:string myControl = new MyControl.WriteToXAML();
不,它不能将C#控件转换为MAUI或Xamarin中的xaml。
我测试了代码并搜索了相关内容,但没有解决方案来实现它。
有关XAML的更多信息,您可以参考official doc

相关问题