Dialog popups?
Posted: 01 Feb 2015, 05:37
How do you make a dialog popup -
MessageBox - with "Do you want to quit?" (Yes/No)
using Neosis inside Unity3d?
MessageBox - with "Do you want to quit?" (Yes/No)
using Neosis inside Unity3d?
Welcome to our official discussion site. You’ll find topics on features, bugs, development, and general support here
https://www.noesisengine.com/forums/
using System;
using Noesis;
[Extended]
[UserControlSource("Assets/UI/MessageBox.xaml")]
public class MessageBox : UserControl
{
public static DependencyProperty TitleProperty = DependencyProperty.Register(
"Title", typeof(string), typeof(MessageBox), new PropertyMetadata(""));
public string Tittle
{
get { return GetValue<string>(TitleProperty); }
set { SetValue<string>(TitleProperty, value); }
}
public static DependencyProperty MessageProperty = DependencyProperty.Register(
"Message", typeof(string), typeof(MessageBox), new PropertyMetadata(""));
public string Tittle
{
get { return GetValue<string>(MessageProperty); }
set { SetValue<string>(MessageProperty, value); }
}
// ...
public void OnPostInit()
{
var root = FindName("LayoutRoot");
root.SetDataContext(this);
}
}
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="MessageBox">
<Grid x:Name="LayoutRoot" Background="#80000000">
<Border BorderBrush="Gray" BorderThickness="1" Background="Silver"
HorizontalAlignment="Center" VerticalAlignment="Center" Margin="200,100">
<StackPanel>
<Border Background="LightSkyBlue" Padding="5,2">
<TextBlock Text="{Binding Title}" FontWeight="Bold"/>
</Border>
<Border Padding="5">
<TextBlock Text="{Binding Message}" TextWrapping="Wrap"/>
</Border>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="5">
<Button Content="{Binding OkText}" Command="{Binding OkCommand}"/>
<Button Content="{Binding CancelText}" Command="{Binding CancelCommand}"/>
</StackPanel>
</StackPanel>
</Border>
</Grid>
</UserControl>
//...
var gui = GetComponent<NoesisGUIPanel>();
var mainWindowRoot = gui.GetRoot<Grid>();
MessageBox msgBox = new MessageBox { Title = "Quit?", Message = "Do you really want to quit?", ... };
mainWindowRoot.GetChildren().Add(msgBox);