WPF - 如何创建与分辨率无关的用户界面
大家好,
Hi All,
我正在设计触摸屏用户界面,用于Kiosk&台式机。
I am designing touch screen User Interface to be used in Kiosk & Desktops machines.
用户界面将以800x600到1920x1080分辨率进行查看。
The User Interface will be view in 800x600 to 1920x 1080 resolutions.
要求: 用户界面内的控件应自动调整大小取决于分辨率
Requirement: Controls inside the User Interface should resize automatically depends on the resolution
以下是方法 我试图实现
Below are the approaches I tried to achieve
方法1:
使用固定大小的网格布局对800x600分辨率的UI进行编码。我使用ViewBox布局封装了Grid,以根据分辨率扩展用户界面。这适用于4:3比例分辨率,如800x600,1024x768。
Coded the UI for 800x600 resolution by using Grid Layout with fixed sizes. I enclosed the Grid with ViewBox layout to stretch the User Interface depending on the resolutions. This works perfect in 4:3 ratio resolutions like 800x600, 1024x768.
问题:
在像1280x800这样的分辨率中,左边和左边的空格是空的;屏幕的右侧。
In resolution like 1280x800 I am getting empty spaces in left & right side of the screen.
方法2:
使用* 0.00宽度和高度的网格编写UI并拉伸水平&控件的垂直对齐 如下所示
Coded the UI using grid with *0.00 width and height and stretched the horizontal & vertical alignment of the controls as below
<网格>
<Grid>
&NBSP; < Grid.ColumnDefinitions>
<Grid.ColumnDefinitions>
< ColumnDefinition Width =" 0.5 *" />
<ColumnDefinition Width="0.5*" />
< ColumnDefinition Width =" 0.5 *" />
<ColumnDefinition Width="0.5*" />
&NBSP; < /Grid.ColumnDefinitions>
</Grid.ColumnDefinitions>
&NBSP; < Grid.RowDefinitions>
<Grid.RowDefinitions>
< RowDefinition Height =" * 0.1 *" />
<RowDefinition Height="*0.1*" />
< RowDefinition Height =" * 0.2 *" />
<RowDefinition Height="*0.2*" />
&NBSP; < /Grid.RowDefinitions>
</Grid.RowDefinitions>
< TextBox HorizontalAlignment =" Stretch" VerticalAlignment = QUOT;拉伸" Grid.Row = QUOT; 0" Grid.Column = QUOT; 0" />
<TextBox HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="0" Grid.Column="0" />
< / Grid>
</Grid>
问题:
1。高度百分比根据行数的不同而不同。每个屏幕都需要花费大量时间来编码和高度标准。
1. Height Percentage ratio various depending on number of rows. Takes lots of time to code and height standards vary for each screens.
2。 Control"ComboBox"拉伸取决于分辨率,但ComboBox项目宽度&高度保持不变。
2. The Control "ComboBox" Stretch depending on resolution, but the ComboBox Item width & Height remains the same.
是否有人指导我在WPF中实现分辨率独立用户界面。
Does Any one guide me to achieve the Resolution Independent User Interface in WPF.
我也面临同样的问题
I am too facing the same issues
如果您有解决方案,请帮助我。
help me if you have a solution.
Manoj。