首页 > 代码库 > XAF ListView 移除顶部工具栏

XAF ListView 移除顶部工具栏

此方法适用于C/S及B/S,无需分别写在web和win中。

Module下新建ViewController,代码如下:

    public partial class GongZuoJiaoShen_YinCangGongJuLan : ViewController<DetailView>    {        public GongZuoJiaoShen_YinCangGongJuLan()        {            InitializeComponent();            // Target required Views (via the TargetXXX properties) and create their Actions.        }        protected override void OnActivated()        {            base.OnActivated();            // Perform various tasks depending on the target View.            //取消记录表的工具栏            foreach (ListPropertyEditor detailPropertyEditor in View.GetItems<ListPropertyEditor>())            {                if (detailPropertyEditor.Id == "JiaoShenJiLu")                    detailPropertyEditor.ControlCreated += new EventHandler<EventArgs>(detailPropertyEditor_ControlCreated);            }        }        /// <summary>        /// 取消记录表的工具栏        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        void detailPropertyEditor_ControlCreated(object sender, EventArgs e)        {            Frame nestedFrame = ((ListPropertyEditor)sender).Frame;            if (nestedFrame != null && nestedFrame.Template is ISupportActionsToolbarVisibility)            {                ((ISupportActionsToolbarVisibility)nestedFrame.Template).SetVisible(false);            }        }        protected override void OnViewControlsCreated()        {            base.OnViewControlsCreated();            // Access and customize the target View control.        }        protected override void OnDeactivated()        {            // Unsubscribe from previously subscribed events and release other references and resources.            base.OnDeactivated();            foreach (ListPropertyEditor detailPropertyEditor in View.GetItems<ListPropertyEditor>())            {                if (detailPropertyEditor.Id == "JiaoShenJiLu")                    detailPropertyEditor.ControlCreated -= new EventHandler<EventArgs>(detailPropertyEditor_ControlCreated);            }        }    }

注意:VC的TargetType要设置,否则就是全局的了。

效果图:

技术分享

XAF ListView 移除顶部工具栏