How to use Right-to-left in Popup.MessageDialog (Metro)

I want to show Right to Left MessageDialog. but it seems that such option does not exist.

I saw a question like this (How to center Popup in Metro style app in c#), but i think that RTL is a different issue.

is the only solution is to write my own "RTL Popup" ? if so, how ?

thank you in advance.

I've tried using this code:

but the result is NOT RTL:

Answers


Since the MessageDialog class is sealed, and there is currently no way to set a property to change the direction to rtl, your best option would be to create your own. One way to do this would be to set a Grid as the last item on a page, with Visibility set to Collapsed and then make it Visible when needed. One way to center it would be like this:

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition/>
        <RowDefinition Height="Auto"/>
        <RowDefinition/>
    </Grid.RowDefinitions>
    <Border Grid.RowSpan="3" Background="Gray" Opacity="0.3"/> <!-- this locks the controls behind-->
    <Border HorizontalAlignment="Stretch" Background="White" Grid.Row="1" Height="300">
        <TextBlock Text="Test" HorizontalAlignment="Center" Width="300"/>
    </Border>
</Grid>

This will vertically center your content, horizontally center it and prevent the user from interacting with any background content until it is Collapsed again.


I don't know any C#, however maybe you could override the messageDialog.OnPaint method. I did this in VB to get the different colored text on a button when enabled was set to false.

Protected Overrides Sub OnPaint(ByVal pevent As System.Windows.Forms.PaintEventArgs)
    If MyBase.Enabled Then
        If Me.Text = "" Then
            MyBase.OnPaint(pevent)
            Dim sf As SizeF = pevent.Graphics.MeasureString("Login", Me.Font, Me.Width)
            Dim ThePoint As New Point((Me.Width / 2) - (sf.Width / 2), (Me.Height / 2) - (sf.Height / 2))
            pevent.Graphics.DrawString("Login", Me.Font, Brushes.Black, ThePoint)
        Else
            MyBase.OnPaint(pevent)
        End If

    Else
        Me.Text = ""
        MyBase.OnPaint(pevent)
        Dim sf As SizeF = pevent.Graphics.MeasureString("Not Ready...", Me.Font, Me.Width)
        Dim ThePoint As New Point((Me.Width / 2) - (sf.Width / 2), (Me.Height / 2) - (sf.Height / 2))
        pevent.Graphics.DrawString("Not Ready...", Me.Font, Brushes.Red, ThePoint)
    End If

End Sub

you can use below Message Dialog in ur method.

var messageDialog = new MessageDialog(" You Can Show Message Here");
                messageDialog.Title = "Alert";
                // Add commands and set their callbacks; both buttons use the same callback function instead of inline event handlers
                messageDialog.Commands.Add(new UICommand(
                    "OK",
                    new UICommandInvokedHandler(this.CommandInvokedHandlerAddPics)));

                messageDialog.Commands.Add(new UICommand(
                    "No",
                    new UICommandInvokedHandler(this.CommandInvokedHandlerback)));

                // Set the command that will be invoked by default
                messageDialog.DefaultCommandIndex = 0;

                // Set the command to be invoked when escape is pressed
                messageDialog.CancelCommandIndex = 1;

                // Show the message dialog
                await messageDialog.ShowAsync();

and method for OK or No button

private void CommandInvokedHandlerAddPics(IUICommand command)
    {
        if (command.Label.Equals("OK"))
        {

        }
        else if (command.Label.Equals("No"))
        {

        }
    }

Need Your Help

How is `Proc#==` evaluated?

ruby equality proc

How is Proc#== evaluated? RDoc says:

Open url with parameters android

java android paypal

Hello I want to open a PayPal uri to pay from android.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.