Ticket T578780
Visible to All Users

Problems when MasterDetailMode = ListViewAndDetailView and UseLightStyle = True

created 7 years ago (modified 7 years ago)

[DevExpress Support Team: CLONED FROM T577264: How to migrate a WinForms application to use the Light Style]
Hi,

Using th e WinApplication.UseLightStyle property has a breaking change which is not listed.

I have a custom controller which is handling the MasterDetailMode.ListViewAndDetailView mode. the View.Control used to be a DevExpress.XtraEditors.SplitContainerControl and has been changed to a Panel…?

I started to debug but inspecting this object make Visual crash.

Thanks for your prompt help

Comments (2)
Dennis Garavsky (DevExpress) 7 years ago

    Hello Maxime,

    Would you please attach your current Controller code? I fear that the View.Control related part is not written in accordance with
    best practices (e.g., if you try to access the layout control). I look forward to hearing from you to find the best solution.

    MM MM
    Maxime MERIAUX 7 years ago
      C#
      public partial class MasterDetailViewControllerWin : ViewController<DevExpress.ExpressApp.ListView> { public MasterDetailViewControllerWin() { InitializeComponent(); // Target required Views (via the TargetXXX properties) and create their Actions. } protected override void OnActivated() { base.OnActivated(); //Frame.GetController<NewObjectViewController>().ObjectCreated += MasterDetailViewControllerWin_ObjectCreated; // choose master detail mode based on root or nested view //ew.Model.MasterDetailMode = View.IsRoot ? MasterDetailMode.ListViewAndDetailView : MasterDetailMode.ListViewOnly; // subscribe to layout event to handle best detail width. if (Frame.Template is Form) { //((Form)Frame.Template).Layout += new LayoutEventHandler(ListViewController_Layout); } } void MasterDetailViewControllerWin_ObjectCreated(object sender, ObjectCreatedEventArgs e) { GridListEditor gridListEditor = View.Editor as GridListEditor; if (gridListEditor != null && e.CreatedObject.Equals(gridListEditor.GridView.GetRow(GridControl.NewItemRowHandle))) { View.EditView.CurrentObject = e.CreatedObject; } } void ListViewController_Layout(object sender, LayoutEventArgs e) { if (View.Model.MasterDetailMode == MasterDetailMode.ListViewAndDetailView && View.EditView != null && View.Control is DevExpress.XtraEditors.SplitContainerControl) { var splitContainer = View.Control as DevExpress.ExpressApp.Win.Layout.SplitContainer; splitContainer.Panel2.MinSize = ((LayoutControl)View.EditView.Control).Root.MinSize.Height; } } protected override void OnViewControlsCreated() { base.OnViewControlsCreated(); // Access and customize the target View control. if (View.Model.MasterDetailMode == MasterDetailMode.ListViewAndDetailView && View.Control is DevExpress.XtraEditors.SplitContainerControl) { var splitContainer = View.Control as DevExpress.ExpressApp.Win.Layout.SplitContainer; splitContainer.FixedPanel = SplitFixedPanel.Panel2; } } protected override void OnDeactivated() { base.OnDeactivated(); // Unsubscribe from previously subscribed events and release other references and resources. Frame.GetController<NewObjectViewController>().ObjectCreated -= new EventHandler<ObjectCreatedEventArgs>(MasterDetailViewControllerWin_ObjectCreated); if (Frame.Template is Form) { //((Form)Frame.Template).Layout -= new LayoutEventHandler(ListViewController_Layout); } } }

      thanks Dennis

      Answers approved by DevExpress Support

      created 7 years ago (modified 7 years ago)

      Hello Maxime,

      The SidePanel with one-pixel borders is used when MasterDetailMode = ListViewAndDetailView to support Light Style. The SidePanel does not have an equivalent for the SplitContainerControl.FixedPanel property option. Our WinForms team will take your scenario into account for the future. We will update the migration guidelines to mention this scenario. Thanks for your input in this regard.

      To set MinimumSize for the left (FlowDirection.Horizontal) or top (FlowDirection.Vertical) part of MasterDetail View, when the Light Style is enabled, you can update your code as follows:

      C#
      void ListViewController_Layout(object sender, LayoutEventArgs e) { if(View.Model.MasterDetailMode == MasterDetailMode.ListViewAndDetailView && View.EditView != null && View.Control is Control) { SidePanel sidePanel = ((Control)View.Control).Controls.OfType<SidePanel>().First(); sidePanel.MinimumSize = new System.Drawing.Size(CustomWidth, CustomHeight); } }

      Thanks,
      Marina

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.