c# - Add window button to dialog -


is possible add window button ("close", "min", "max") modernui dialog?

moderndialog.showmessage("dialog", "how add window buttons?"); 

i not find information.

a dialog modal default , design. shouldn't use min/max on them. action buttons on dialog perform close function.

that said, implemented own dialoghelper adapt:

public enum messagetype {     none = 0,     error = 16,     stop = error,     hand = error,     question = 32,     warning = 48,     exclamation = warning,     information = 64,     asterisk = information }  public static class dialoghelper {     public static bool? showmessage(string text, string title, messagetype messagetype = messagetype.none)     {         var dlg = new moderndialog();         dlg.buttons = new[] {dlg.okbutton};         dlg.title = title;         dlg.content = text;         dlg.backgroundcontent = new dialogbackgroundcontent(messagetype);         dlg.minwidth = dlg.minwidth + 200;          bool? res = false;         dispatcher.currentdispatcher.begininvoke(new action(() => res = dlg.showdialog()));         return res;     } } 

i did abstract away modern ui framework, in case wanted swap out else later.

dialogbackgroundcontent xaml usercontrol i'm using decorate background success/fail icon.

<usercontrol x:class="cmc.installer.core.controls.dialogbackgroundcontent"              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"               xmlns:d="http://schemas.microsoft.com/expression/blend/2008"               mc:ignorable="d"               d:designheight="300" d:designwidth="300">     <grid>         <path x:name="successicon" width="32" height="32" stretch="fill" fill="#ff00ff00"                margin="0,32,32,0"               horizontalalignment="right" verticalalignment="top"               data="m-150.204,626.126c-152.317,626.126 -154.429,626.126 -156.541,626.126 -167.642,633.42 -180.629,646.047 -189.668,657.238 -190.916,658.782 -192.945,662.362 -193.701,662.422 -194.041,662.448 -198.024,659.719 -198.614,659.297 -202.818,656.279 -205.779,653.709 -209.257,650.899 -211.248,652.172 -212.879,653.805 -214.153,655.797 -206.627,665.074 -200.283,675.534 -193.124,685.18 -181.491,665.11 -168.473,644.683 -152.796,629.006 -151.735,627.946 -149.817,626.933 -150.204,626.126z"/>          <path x:name="failureicon" visibility="hidden" width="32" height="32" stretch="fill" fill="#ffff0000"                margin="0,32,32,0"               horizontalalignment="right" verticalalignment="top"               data="m50,5c25.147,5,5,25.147,5,50c0,24.853,20.147,45,45,45s45-20.147,45-45c95,25.147,74.853,5,50,5z m55,75h45v65h10v75z   m55,60h45v25h10v60z"/>     </grid> </usercontrol>   public partial class dialogbackgroundcontent : usercontrol     {         public dialogbackgroundcontent(messagetype messagetype = messagetype.none)         {             initializecomponent();              switch (messagetype)             {                 case messagetype.none:                     failureicon.visibility = visibility.hidden;                     successicon.visibility = visibility.hidden;                     break;                 case messagetype.error:                     failureicon.visibility = visibility.visible;                     successicon.visibility = visibility.hidden;                     break;                 case messagetype.question:                     break;                 case messagetype.warning:                     break;                 case messagetype.information:                     failureicon.visibility = visibility.hidden;                     successicon.visibility = visibility.visible;                     break;                 default:                     throw new argumentoutofrangeexception("messagetype");             }         }     } 

you might want try swapping out moderndialog modernwindow in function more flexibility.

modernwindow defined here: https://github.com/firstfloorsoftware/mui/blob/master/1.0/firstfloor.modernui/shared/windows/controls/modernwindow.cs


Comments