xaf--自定义窗口标题

 

 

 

第二种效果:

public partial class CustomizeWindowController : WindowController
    {
        public CustomizeWindowController()
        {
            TargetWindowType = WindowType.Main;
        }

        protected override void OnActivated()
        {
            base.OnActivated();
            WindowTemplateController controller = Frame.GetController<WindowTemplateController>();
            controller.CustomizeWindowCaption += Controller_CustomizeWindowCaption;
        }

        private void Controller_CustomizeWindowCaption(object sender, CustomizeWindowCaptionEventArgs e)
        {
            //e.WindowCaption.Text = "我是窗口标题";
            e.WindowCaption.SecondPart += " (Powered by XAF)";
        }

        protected override void OnDeactivated()
        {
            base.OnDeactivated();
            WindowTemplateController controller = Frame.GetController<WindowTemplateController>();
            controller.CustomizeWindowCaption -= Controller_CustomizeWindowCaption;
        }
    }
View Code

 

 

 

 

 第三种效果:自定义分隔符号(默认是一个Dash)

public partial class CustomizeWindowController : WindowController
    {
        public CustomizeWindowController()
        {
            TargetWindowType = WindowType.Main;
        }

        protected override void OnActivated()
        {
            base.OnActivated();
            WindowTemplateController controller = Frame.GetController<WindowTemplateController>();
            controller.CustomizeWindowCaption += Controller_CustomizeWindowCaption;
        }

        private void Controller_CustomizeWindowCaption(object sender, CustomizeWindowCaptionEventArgs e)
        {
            //e.WindowCaption.Text = "我是窗口标题";
            e.WindowCaption.SecondPart += " (Powered by XAF)";
            e.WindowCaption.Separator = "";
        }

        protected override void OnDeactivated()
        {
            base.OnDeactivated();
            WindowTemplateController controller = Frame.GetController<WindowTemplateController>();
            controller.CustomizeWindowCaption -= Controller_CustomizeWindowCaption;
        }
    }
View Code

 

 

 

  

 

 第四种:前后两部分,位值互换

private void Controller_CustomizeWindowCaption(object sender, CustomizeWindowCaptionEventArgs e) {
    string TmpString = e.WindowCaption.FirstPart;
    e.WindowCaption.FirstPart = e.WindowCaption.SecondPart;
    e.WindowCaption.SecondPart = TmpString;
}
View Code

 

 

 

第五种:前后两部分,只展示一部分

 

 

 

(完) 

 

posted @ 2021-09-18 11:30  lishidefengchen  阅读(37)  评论(0编辑  收藏  举报