自定义消息框未显示在Windows Phone 8中

时间:2015-05-28 08:32:29

标签: c# windows-phone-8.1

我正在开发Windows Phone应用程序。我必须将图像转换为二进制数组,我必须通过Web服务(//一些代码)将这些细节发送到后端。所以这个过程需要一些时间。我把这个自定义消息框显示为保存过程。但是没有显示此自定义消息框。这是为什么?

提前致谢。

private CustomMessageBox cmd;//global variable

private void Save_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtSignby.Text.ToString()) && MyIP.Strokes != null && MyIP.Strokes.Count > 0)
            {
                WriteableBitmap wbBitmap = new WriteableBitmap(MyIP, new TranslateTransform());
                EditableImage eiImage = new EditableImage(wbBitmap.PixelWidth, wbBitmap.PixelHeight);

                cmd = new CustomMessageBox()
                {
                    Caption = "SAVING....",
                    Message = "Please wait...."
                };
                cmd.Show();

                //some code
                //some code
                //some code
                //some code

                cmd.Dismiss();
}
}

使用Microsoft.Phone.Controls.Toolkit.dll

自定义消息框类
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;

namespace Microsoft.Phone.Controls
{
    [TemplatePart(Name = "CaptionTextBlock", Type = typeof(TextBlock))]
    [TemplatePart(Name = "LeftButton", Type = typeof(ButtonBase))]
    [TemplatePart(Name = "MessageTextBlock", Type = typeof(TextBlock))]
    [TemplatePart(Name = "RightButton", Type = typeof(ButtonBase))]
    [TemplatePart(Name = "TitleTextBlock", Type = typeof(TextBlock))]
    public class CustomMessageBox : ContentControl
    {
        public static readonly DependencyProperty CaptionProperty;
        public static readonly DependencyProperty IsFullScreenProperty;
        public static readonly DependencyProperty IsLeftButtonEnabledProperty;
        public static readonly DependencyProperty IsRightButtonEnabledProperty;
        public static readonly DependencyProperty LeftButtonContentProperty;
        public static readonly DependencyProperty MessageProperty;
        public static readonly DependencyProperty RightButtonContentProperty;
        public static readonly DependencyProperty TitleProperty;

        public CustomMessageBox();

        public string Caption { get; set; }
        public bool IsFullScreen { get; set; }
        public bool IsLeftButtonEnabled { get; set; }
        public bool IsRightButtonEnabled { get; set; }
        public object LeftButtonContent { get; set; }
        public string Message { get; set; }
        public object RightButtonContent { get; set; }
        public string Title { get; set; }

        public event EventHandler<DismissedEventArgs> Dismissed;
        public event EventHandler<DismissingEventArgs> Dismissing;

        public void Dismiss();
        public override void OnApplyTemplate();
        public void Show();
    }
}

1 个答案:

答案 0 :(得分:0)

您需要让UI线程稍微运行才能显示自定义消息框。一种方便的方法是使用async / await关键字:

The left hand side is initialized and has an empty range of indices.
However, the right hand side returned one or more results.
Error in fff (line 4)
Sections{1,2}{:,1} = TEXT{3:10,1}; % Text in the section