Пример #1
0
    public static MessageBoxResult Show(
        object msg,
        MessageBoxImage img,
        MessageBoxButton buttons = MessageBoxButton.OK,
        string details           = null)
    {
        MessageBoxResult fn()
        {
            MessageBoxEx.DetailsText = details;
            return(MessageBoxEx.OpenMessageBox((msg ?? "").ToString().Trim(),
                                               WinForms.Application.ProductName, buttons, img));
        }

        ApartmentState state = Thread.CurrentThread.GetApartmentState();

        if (state == ApartmentState.STA)
        {
            return(fn());
        }
        else
        {
            return(Application.Current.Dispatcher.Invoke(fn));
        }
    }