2014-06-30 34 views
0

我有一個使用木衛四工具箱和CustomDialog控制等待響應使用木衛四CustomDialog

裏面一個foreach我展示CustomDialog一個Windows商店應用。問題是我需要等待用戶響應,我的意思是,等待點擊按鈕事件(按鈕1或按鈕2)

用MessageDialog很容易,您只需要等待dialog.ShowAsync() ;

<callisto:CustomDialog x:FieldModifier="public" x:Name="JustATest" 
    Background="White" BackButtonVisibility="Collapsed" Title="Some title"> 
    <StackPanel Width="500"> 
     <TextBlock Margin="0,0,0,8" FontSize="14.6667" FontWeight="SemiLight" TextWrapping="Wrap"> 
      <Run x:Name="txt1" Text="Some random sample text.."/> 
     </TextBlock> 
     <CheckBox Margin="0,20,0,8" Content="Some checkbox" /> 

     <StackPanel Margin="0,20,0,0" HorizontalAlignment="Right" Orientation="Horizontal"> 
      <Button Content="button 1" Width="80" Margin="0,0,20,0" /> 
      <Button Content="button 2" Width="80" /> 
     </StackPanel> 
    </StackPanel> 
</callisto:CustomDialog> 
+0

您可以發佈您的foreach部分的代碼? – loop

回答

1

1)WinRT XAML Toolkit - AsyncUI庫

2)using WinRTXamlToolkit.AwaitableUI;

3)public async Task<bool> ShowDialogAsync(....) { ....... this.Dialog.IsOpen = true; //add buttons to awaitable var buttons = new List<ButtonBase>(); buttons.Add(btnOK); buttons.Add(btnCancel); //wait for result var clickedButton = await buttons.WaitForClickAsync(); //close popup this.Dialog.IsOpen = false; ....... //return result return clickedButton.Name.Contains("btnOK"); }

4)var result = await ShowDialogAsync();