gayan1991
gayan1991

Reputation: 795

How to show a Customized MessageBox?

I want to show something like MessageBox in my windows 8 phone App, Unfortunately I am not able to find a way to do it.

Test.Show("Desc", "Title");

and my method in DLL

public static class Test
{
    public static void Show(object buttonsContent, object title)
    {

    }
}

How can I show my Customized MessageBox in class library in APP.....

Upvotes: 0

Views: 380

Answers (5)

Rev
Rev

Reputation: 33

You can create a popup control on XAML design page like this

   <Popup x:Name="_Popup">
   <Border  Margin="30,190,24,194" CornerRadius="17" BorderThickness="3" BorderBrush="Gray" Background="White" Opacity="0.9">
   <Grid x:Name="MsgPanel" Grid.Row="1" VerticalAlignment="Center" Height="250">
    <TextBlock Name="txtTitle" Text="Message" Foreground="Black" FontSize="28" HorizontalAlignment="Center" FontFamily="Calibri" Height="39" VerticalAlignment="Top" /> 
   <Border Margin="6,70,6,105" BorderBrush="Black" CornerRadius="17" BorderThickness="3">
     <TextBox Name="txtmsgMobNo" Background="{x:Null}" BorderBrush="{x:Null}" Foreground="Black" MaxLength="10" FontSize="25" FontFamily="Courier New" FontWeight="Bold">
     </TextBox>
     </Border>
    <Border Margin="58,150,222,40" CornerRadius="10" BorderThickness="3" Background="Silver" BorderBrush="Gray">
    <Button Name="btnMsgSend" Content="Send" BorderBrush="{x:Null}" Background="{x:Null}" Foreground="Black" Height="68" Width="144" Click="btnMsgSend_Click" Margin="0,-10,0,0"></Button>
     </Border>
     </Grid>
            </Border>
        </Popup>

And in the code behind wherever you want to open the popup, put _Popup.Isopen = true;

Upvotes: 0

vITs
vITs

Reputation: 1560

you can use ChildWindow class that provides a window that can be displayed over a parent window.

you can check example here

Upvotes: 0

Kaj
Kaj

Reputation: 333

You can easily re-style the CustomMessageBox control of the Windows Phone Toolkit . You need to open a .xaml file in Blend and edit a copy of the style of a CustomMessageBox, so you can use it in your own projects. You can add your own content within the ControlTemplate of this style. You then copy this style to a place where you can access it, in the example below I put it in the App.xaml file. You declare the CustomMessageBox like this:

new CustomMessageBox
   {
        Caption = "A messagebox",
        Style = App.Current.Resources["YourEditedStyleKey"] as Style,
   }.Show();

You can control the TemplateBinding on various properties that you can set on the CustomMessageBox. For example, you can set a custom font

FontFamily = App.Current.Resources["MuseoSans500"] as FontFamily,

And use a template binding in your custom style to use this font:

FontFamily="{TemplateBinding FontFamily}"

Upvotes: 0

Johan Paul
Johan Paul

Reputation: 2456

Because in this example that you've given us you are passing two String objects to the Show(object, object) method, you could just use MessageBox.Show(String, String, MessageBoxButton) to show a dialog.

But if you intend to show something other than text in the MessageBox, then you have to implement a dialog view yourself. This can be done quite easily using the PopUp class (http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.primitives.popup). It will custom content on top of the existin view into which you can place your content along with dialog buttons, that you then can handle.

Upvotes: 0

Related Questions