C# 使用不同的屏幕自动调整outlook自定义任务窗格的大小
我已经创建了outlook加载项并向其添加了自定义任务窗格C# 使用不同的屏幕自动调整outlook自定义任务窗格的大小,c#,vsto,outlook-addin,autosize,customtaskpane,C#,Vsto,Outlook Addin,Autosize,Customtaskpane,我已经创建了outlook加载项并向其添加了自定义任务窗格 private void ThisAddIn_Startup(object sender, System.EventArgs e) { taskpane = this.CustomTaskPanes.Add(new UCMaster(), "Summit Service Management"); UserControl ucmaster = taskpane.Cont
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();
}
这里我根据我的屏幕尺寸和分辨率对任务窗格的宽度进行硬编码,看起来很合适
但是,在不同的屏幕上,我观察到任务窗格被压缩或以任何其他方式
我的问题是如何根据当前系统屏幕分辨率和尺寸动态更改任务窗格宽度 对于容器控件,“AutoScaleMode”应为Inherit,对于叶控件应为Font。
试试这个:
ucmaster.AutoScaleMode=AutoScaleMode.Inherit;
和
将您的子用户控件设置为:
ucChild.AutoScaleMode=AutoScaleMode.Font