我有一个共享代码,而不是PCL,不使用XAML的演示项目。内容仅使用代码呈现。 Android项目按预期工作
我试图弄清楚如何连接基本的UWP项目。
UWP项目提到了Xamarin表格
共享Xamarin项目,是一个基本的标签和输入字段
public partial class App : Application { // NOT XAML
public App() {
MainPage = new Demo.MainPage();
}
.... }
public class MainPage : ContentPage { // NOT XAML
Entry phoneNumberText;
public MainPage (){
var prompt = new Label();
prompt.Text = "Phoneword";
phoneNumberText = new Entry();
var panel = new StackLayout();
panel.Children.Add(prompt);
panel.Children.Add(phoneNumberText);
this.Content = panel;
}
Droid项目哪个有效
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity {
protected override void OnCreate (Bundle bundle) {
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate (bundle);
global::Xamarin.Forms.Forms.Init (this, bundle);
LoadApplication (new Demo.App ());
}
}
我应该在UWP项目中添加什么来使用共享(非PCL)Xamarin项目 我看过Xamarin docu for add UWP project to Solution 但它假设您正在使用XAML。
UWP代码到目前为止
public App() {
this.Suspending += OnSuspending;
}
protected override void OnLaunched(LaunchActivatedEventArgs e) {
Frame rootFrame = Window.Current.Content as Frame;
if (rootFrame == null) {
// Create a Frame to act as the navigation context and navigate to the first page
rootFrame = new Frame();
rootFrame.NavigationFailed += OnNavigationFailed;
Xamarin.Forms.Forms.Init(e);
.... Now what should I do, what is missing.
public partial class MainPage : Page {
public MainPage() {
LoadApplication(new Demo.App()); // LoadApplication not found...
**?? What should i do here ???**
}
}
答案 0 :(得分:1)
您仍然需要MainPage.xaml才能使用xamarin表单。此页面将呈现xamarin表单。 xamarin表单可以包含在所有代码中。本指南应该可以帮助您入门。
https://developer.xamarin.com/guides/xamarin-forms/platform-features/windows/installation/universal/