【问题标题】:Wait for response using Callisto CustomDialog使用 Callisto CustomDialog 等待响应
【发布时间】:2014-08-20 09:25:13
【问题描述】:

我有一个使用 Callisto 工具包和 CustomDialog 控件的 Windows 应用商店应用程序

在 FOREACH 中,我展示了 CustomDialog。问题是我需要等待用户响应,我的意思是,等待点击按钮事件(按钮 1 或按钮 2)

MessageDialog很简单,你只需要await 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>

【问题讨论】:

  • 你能发布你的foreach部分代码吗?

标签: c# xaml windows-8 customdialog callisto


【解决方案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();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-03
    • 2020-09-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多