在Xamarin表单中的Modal Popup上忽略了命令绑定

时间:2016-08-03 15:37:13

标签: c# xaml modal-dialog xamarin.forms

我有一个Xamarin Forms Photo应用程序(附件),用于使用本机代码(iOS)实现拍照

App.xaml.cs

  public App() {
        MainPage = new NavigationPage(new StartPage());
  }

StartPage.xaml.cs

这有两个功能

  private async void FullScreen_Clicked(object sender, EventArgs e)   {
        await Navigation.PushAsync(new TakePicturePage(), true);
  }

  private async void Modal_Clicked(object sender, EventArgs e) {
        await Navigation.PushModalAsync(new TakePicturePage(), true);
  }

启动Navigation.PushAsyncModel时,页面会加载,但命令永远不会被提升

TakePicturPage的代码如下:

public TakePicturePage()
    {
        InitializeComponent();
        BindingContext = new TakePictureViewModel(DependencyService.Get<ICameraProvider>());
    }

XAML代码

 <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"         x:Class="CameraApplication.Views.TakePicturePage">
        <StackLayout>
                  <Button Text="Take a Picture Test" Command="{Binding TakePicture}" />
                  <Image Source="{Binding Picture}"/>
        </StackLayout>
 </ContentPage>

示例代码: -

https://forums.xamarin.com/discussion/72771/command-bindings-ignored-on-modal-popup-page/p1?new=1

0 个答案:

没有答案