【发布时间】:2020-04-30 09:55:38
【问题描述】:
我在下面的面板中有三个控件。我必须在面板的中心安排一个。其他两个应该放在中心一个的左右两侧。 我已经尝试过如下。但是让所有三个控件都向左对齐。请帮忙改正。
<WindowsFormsHost x:Name="windowsFormsHost1" Grid.Row="5" Grid.ColumnSpan="3" Initialized="WindowsFormsHost_Initialized" HorizontalAlignment="Center" VerticalAlignment="Center" >
<wf:Panel x:Name="Panel_glcontrol" Dock="None" BackColor="yellow" >
<wf:Panel.Controls>
<opentk:GLControl x:Name="glControl" Width="450" Height="299" Dock="None" Visible="True" MouseMove="GlControl_MouseMove" MouseDown="GlControl_MouseDown" Resize="glControl_Resize" Paint="glControl_Paint" />
<opentk:GLControl x:Name="glControl2" Width="450" Height="299" Dock="None" MouseDown="GlControl2_MouseDown" MouseMove="GlControl2_MouseMove" Visible="True" Resize="glControl2_Resize" Paint="glControl2_Paint" />
<opentk:GLControl x:Name="glControl3" Width="450" Dock="None" Height="299" Visible="True" MouseDown="GlControl3_MouseDown" MouseMove="GlControl3_MouseMove" Resize="glControl3_Resize" Paint="glControl3_Paint" />
</wf:Panel.Controls>
</wf:Panel>
</WindowsFormsHost>
glControl2.Location = new System.Drawing.Point((_Screenwidth / 2) - glControl2.Width / 2, (_Screenheight - glControl.Height) / 2);
glControl.Location = new System.Drawing.Point(glControl2.Location.X - glControl.Width - 5, (_Screenheight - glControl2.Height) / 2 );
glControl3.Location = new System.Drawing.Point(glControl2.Location.X + glControl2.Width + 5, (_Screenheight - glControl3.Height) / 2 );
【问题讨论】:
标签: c# wpf panel windowsformshost