Search code examples
c#messageboxpixelsense

c# Messagebox for touchscreen


I need a touch enabled message box for a surface 2.0 application. The standard MessageBox.Show() has to be confirmed with a mouse click.

That is not what I want.

I could write a small UserControl, but I wonder if there is something already integrated.


Solution

  • I did it myself, after searching nearly an hour or so ^^

    public partial class MsgBoxTouch : SurfaceWindow
        {
            public TouchBox1()
            {
                this.InitializeComponent();                
    
            }
    
            private void Button_TouchEnter(object sender, TouchEventArgs e)
            {
                this.Close();
            }
    
    
        }
    }
    
    <s:SurfaceWindow x:Class="MsgBoxTouch"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:s="http://schemas.microsoft.com/surface/2008"
        mc:Ignorable="d" 
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    
    
        WindowState="Normal" WindowStyle="None" Width="300" Height="300">
    
        <Grid x:Name="Layout">
    
            <Button Content="OK" Height="50" TouchEnter="Button_TouchEnter">
    
            </Button>
        </Grid>
    </s:SurfaceWindow>