当前位置: 移动技术网 > IT编程>开发语言>.net > WPF PrismDialog PopupWindowAction使用MetroWindow

WPF PrismDialog PopupWindowAction使用MetroWindow

2019年04月05日  | 移动技术网IT编程  | 我要评论

qq飞车补丁下载,东周英雄传,三菱电梯故障代码

本示例必须在prism5.0版本以上

popupwindowaction如何使用metrowindow?

 

public class window1viewmodel:bindablebase,iinteractionrequestaware
    {
        #region properties
        private string str;

        public string str
        {
            get { return str; }
            set { setproperty(ref str, value); }
        }

        #endregion

        /// <summary>
        /// cancel
        /// </summary>
        private delegatecommand<window> clickcommand;

        public delegatecommand<window> clickcommand
        {
            get
            {
                if (clickcommand == null)
                    clickcommand = new delegatecommand<window>(click);
                return clickcommand;
            }
        }

        private inotification  notification;

        public inotification notification
        {
            get { return notification; }
            set { setproperty(ref notification,value); }
        }

        public action finishinteraction { get; set; }

        private void click(window window)
        {
            var _notification = (window1dialogmodel)notification;
            _notification.str = this.str;
            _notification.confirmed = true;
            finishinteraction?.invoke();
        }
    }

 

  public class window1dialogmodel : iconfirmation
    {
        public string str { get; set; }

        //interface content
        public bool confirmed { get ; set ; }
        public string title { get ; set ; }
        public object content { get; set; }
    }

 

<usercontrol x:class="pfu.scansnap.home.ui.sshuiuserdata.views.window1"
                           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                           xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
                           xmlns:metrocontrols="clr-namespace:mahapps.metro.controls;assembly=mahapps.metro"
                           xmlns:prism="http://www.codeplex.com/prism"
                           xmlns:prop="clr-namespace:pfu.scansnap.home.ui.sshuiuserdata.properties"
                           xmlns:util ="clr-namespace:pfu.scansnap.home.ui.sshuiuserdata.util"
                           prism:viewmodellocator.autowireviewmodel="true"
                           mc:ignorable="d"
                           borderbrush="#ff666666"
                           borderthickness="1"
                           width="500" height="300">
    <usercontrol.resources>
        <resourcedictionary>
            <resourcedictionary.mergeddictionaries>
                <resourcedictionary  source="/sshuiuserdata;component/styles/resourcedictionary.xaml"/>
                <resourcedictionary  source="/sshuiuserdata;component/styles/basestyles.xaml" />

                <resourcedictionary source="pack://application:,,,/mahapps.metro;component/styles/controls.buttons.xaml" />
                <resourcedictionary source="pack://application:,,,/mahapps.metro;component/styles/colors.xaml" />
            </resourcedictionary.mergeddictionaries>
        </resourcedictionary>
    </usercontrol.resources>

    <grid>
        <stackpanel orientation="vertical" verticalalignment="center">
            <textbox text="{binding str}"/>
            <button content="click" command="{binding clickcommand}" commandparameter="{binding elementname=_window1_}"/>
        </stackpanel>
    </grid>
</usercontrol>

 

// 核心块

 public class metropopupwindowaction:popupwindowaction
    {
        protected override window createwindow()
        {
            return new messagedialogwindow();
        }
    }

 

<!--window1 dialog-->
        <prism:interactionrequesttrigger sourceobject="{binding window1dialogrequest}">
            <util:metropopupwindowaction ismodal="true" centeroverassociatedobject="true">
                <util:metropopupwindowaction.windowcontent>                   
                    <local:window1/>
                </util:metropopupwindowaction.windowcontent>
            </util:metropopupwindowaction>
        </prism:interactionrequesttrigger>

 

private void ok()
        {
            window1dialogrequest.raise(new window1dialogmodel { str = $"6666", title = "window1" }, _ =>
            {
                messagebox.show(_.str);
            });
        }
        #endregion

        #region notificationrequest
        public interactionrequest<window1dialogmodel> window1dialogrequest { get; set; }
        #endregion

        public exportmainwindowviewmodel()
        {
            window1dialogrequest = new interactionrequest<window1dialogmodel>();
        }

 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网