Example #1
0
        public MessageBoxView(Window owner, MessageBoxOptions options)
        {
            // Theme and Icon must be set BEFORE Avalonia loads the XAML
            // in order to avoid awkward behaviors
            this.SetStyle(options.GetStyleUri());
            if (owner != null && options.UseOwnerIcon)
            {
                Icon = owner.Icon;
            }
            else
            {
                this.SetIcon(options.WindowIconUri);
            }

            InitializeComponent();

            // CanResize must be set BEFORE SizeToContent
            // https://github.com/AvaloniaUI/Avalonia/issues/3360
            CanResize            = options.CanResize;
            SizeToContent        = SizeToContent.WidthAndHeight;
            HasSystemDecorations = options.HasSystemDecorations;

            DockPanel panel = this.Find <DockPanel>("ContentPanel");

            if (options.MaxHeight > 0)
            {
                panel.MaxHeight = options.MaxHeight;
            }
            if (options.MaxWidth > 0)
            {
                panel.MaxWidth = options.MaxWidth;
            }
        }