消息对话框未在Windows 8平板电脑上显示 - Caliburn.Micro / C#

时间:2013-05-02 14:17:04

标签: windows-8 microsoft-metro caliburn.micro tablet-pc messagedialog

有没有人听说过MessageDialog没有在Windows 8平板电脑上显示的任何问题?或者更具体的是三星700t?它使用常规的intel进程,而不是ARM。我在笔记本电脑上构建了应用程序,并且在使用笔记本电脑进行调试时显示的消息对话显示在平板电脑模拟器上,但未在实际平板电脑上显示。

我正在使用Caliburn.Micro IResult界面在视图中显示messagedialog。

下面我正在使用的代码:

public IEnumerable<IResult> NavExecute(String method)
{
    Windows.UI.ViewManagement.ApplicationView.TryUnsnap();
    var conn = NetworkInformation.GetInternetConnectionProfile();
    if (conn.GetNetworkConnectivityLevel() != NetworkConnectivityLevel.InternetAccess)
    {
        yield return new MessageDialogResult("Internet Connection Not Detected", "Connection Error");
        netOn = false;

    }

} 以上是我的视图模型基类,并且继承了IResult类本身的实现:

public class MessageDialogResult : ResultBase
{
    private readonly string _content;
    private readonly string _title;

    public MessageDialogResult(string content, string title)
    {
        _content = content;
        _title = title;
    }

    public async override void Execute(ActionExecutionContext context)
    {
        var dialog = new MessageDialog(_content, _title);

        await dialog.ShowAsync();

        OnCompleted();
    }
}

我怀疑这是代码的问题,因为我在两个设备上以x86模式进行调试(之前有人问为什么我没有为所有设备调试它,因为我使用SQLite需要一个单独的包每个arhitecture。)

我不确定Windows 8中的某个设置是否会在应用弹出窗口中禁用,但我找不到。

有什么想法吗?

2 个答案:

答案 0 :(得分:1)

您是否正在处理Coroutine.Execute的回调?

Execute上的回调可能会回调,并且协程抛出异常 - 如果您没有在回调中明确查找它,这将无声地失败

Coroutine.Execute(YourEnumerator(), new ActionExecutionContext { Blah }, (o, e) => {
    if(e.Error != null) // Something went wrong
});

也许async等待投掷或类似的东西(不能想到为什么!)

编辑:

你的枚举器中的其他内容也可以抛出:

Windows.UI.ViewManagement.ApplicationView.TryUnsnap();
var conn = NetworkInformation.GetInternetConnectionProfile();

如果没有在回调中处理,任何一个人都可以抛出外部枚举器吞下异常 - 或者可能是conn上的nullref?

答案 1 :(得分:1)

GetInternetConnectionProfile()返回空引用的原因是因为在笔记本电脑上,如果断开无线连接,笔记本电脑的互联网连接配置文件默认为以太网,而平板电脑(至少是三星700T) )没有以太网端口,因此如果未建立无线连接,则其连接配置文件不存在。

感谢Charleh指出我正确的方向。