2

我创建了一个 Outlook 插件并向其中添加了一个自定义任务窗格

private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {  
            taskpane = this.CustomTaskPanes.Add(new UCMaster(), "Summit Service Management");
            UserControl ucmaster = taskpane.Control;
            eh = new ElementHost { Child = new WPFUCMaster(new WPFUCLogin()) };
            eh.Dock = DockStyle.Fill;
            eh.AutoSize = true;
            ucmaster.Controls.Add(eh);
            taskpane.DockPosition = Office.MsoCTPDockPosition.msoCTPDockPositionRight;
            taskpane.DockPositionRestrict = Office.MsoCTPDockPositionRestrict.msoCTPDockPositionRestrictNoChange;
            taskpane.Width = 460;
            taskPaneWidth = taskpane.Width;
            taskPaneHeight = taskpane.Height;
            ucmaster.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right);        
            ucmaster.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            ucmaster.AutoSize = true;
            int h = ucmaster.Height;
            int w = ucmaster.Width;
            initialAddinInstance = this;
            ucmaster.BringToFront();
        }

在这里,我根据我的屏幕尺寸和分辨率对任务窗格宽度进行硬编码,它看起来很合适。

但是,在不同的屏幕上,我观察到任务窗格被压缩或以任何其他方式。

我的问题是如何根据当前系统屏幕分辨率和尺寸动态更改任务窗格宽度?

4

1 回答 1

1

对于 Container 控件,“AutoScaleMode”应该是 Inherit,对于 Leaf Controls,它应该是 Font。试试这个:ucmaster.AutoScaleMode = AutoScaleMode.Inherit; 并使您的孩子用户控制: ucChild.AutoScaleMode = AutoScaleMode.Font;

于 2016-07-26T15:47:15.040 回答