PageRenderer 사용에 문제가 있습니다.Xamarin Forms UWP PageRenderer
MainPage.xml
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="abc.CustomView">
<ContentPage.Content>
<StackLayout>
<Button Text="scann" Clicked="BtnScannClicked"></Button>
</StackLayout>
</ContentPage.Content>
MainPage.cs
async void BtnScannClicked(object sender, EventArgs e)
{
await Navigation.PushAsync(new CustomView());
}
CustomView.Xaml
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="abc.CustomView">
<ContentPage.Content>
</ContentPage.Content>
</ContentPage>
CustomView.cs
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class CustomView : ContentPage
{
public CustomView()
{
InitializeComponent();
}
}
,174 (내 인 CustomRenderer입니다)
DemoPage.cs
[assembly: ExportRenderer(typeof(CustomView), typeof(DemoPage))]
namespace abc.UWP
{
class DemoPage: PageRenderer
{
Page page;
Application app;
protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.Page> e)
{
base.OnElementChanged(e);
if (e.OldElement != null || Element == null)
{
return;
}
try
{
app = Application.Current;
SetupUserInterface();
this.Children.Add(page);
}
catch (Exception ex)
{
Debug.WriteLine(@" ERROR: ", ex.Message);
}
}
void SetupUserInterface()
{
var stackPanel = new StackPanel();
page = new Page();
page.Content = stackPanel;
}
}
}
예외 던져 항상있다 : 빌드하는 동안 Xamarin.Forms.Platform.UAP.dll 오류 'System.InvalidOperationException'가.
하지만 이것이 실제로 PageRenderer에 문제가되지는 않는다고 생각합니다. 이것이 ClickEvent 중에 나타나는 것으로 보입니다.
ok, 문제는 PushModalAsync 대신 Navigation.PushAnsync를 사용하는 것이 었습니다. 이제 내비게이션 파트가 작동하는 것 같습니다 (내 DemoPage.cs의 exportRenderer 어셈블리 없이는). 내 응용 프로그램은 DemoPage.cs 탐색 후 항상 충돌 (종료 코드 -1이 있음)됩니다. 구현은 괜찮은지 아닌지 여부 – flix