[英]Is there any default strategy to prepare application for a resolution change?
How to prepare a Silverlight or WPF application to change from a big resolution to a small resolution? 如何准备Silverlight或WPF应用程序从大分辨率更改为小分辨率?
I guess using dockpanel strategy only works for changing from a small to a big resolution. 我想使用dockpanel策略只适用于从小分辨率变为大分辨率。
So, is there any default strategy? 那么,有没有默认策略? Thanks.
谢谢。
Problem: I have a button the ends in the pixel 1024, 768. And I change the resolution to 800x600. 问题:我有一个按钮,像素1024,768的末端。我将分辨率更改为800x600。
Some time ago I had a similar issue. 前段时间我有类似的问题。 As a workaround I surrounded the window content in a Viewbox .
作为一种解决方法,我在Viewbox中包含了窗口内容。
Users that used 1024x768 instead of 1280x1024 see the application content smaller, but they preferred this than scrolling all the time. 使用1024x768而不是1280x1024的用户会看到应用程序内容较小,但他们更喜欢这一点,而不是一直滚动。 (WPF)
(WPF)
I'll have to work on this for our next project, let's hope somebody has better ideas! 我将不得不为下一个项目做这个工作,希望有人有更好的想法!
Well, you could design your layout to Stretch and designing it with 800x600 in mind, so whenever the layout becomes larger than 800x600 it will fit. 那么,您可以将您的布局设计为Stretch并考虑800x600进行设计,因此每当布局大于800x600时,它都适合。 But...
但...
if you really want something fancy, detect the change in the window size/ActualHeight and ActualWidth (using SizeChanged) then scale the the application according to size via code (using dynamic transforms). 如果你真的想要一些花哨的东西,检测窗口大小/ ActualHeight和ActualWidth(使用SizeChanged)的变化,然后通过代码(使用动态变换)根据大小缩放应用程序。
For example, in the "LayoutRoot" in your main view: 例如,在主视图中的“LayoutRoot”中:
var x = new ScaleTransform();
x.ScaleX = .5; // Do fancy computation here
x.ScaleY = .5; // Do fancy computation here
this.LayoutRoot.RenderTransform = x;
Just an idea, i mean if the screen is bigger than your design you enlarge and vice versa. 只是一个想法,我的意思是如果屏幕比你的设计大,你放大,反之亦然。
Hope this helps. 希望这可以帮助。
I think doing this way is better: 我认为这样做更好:
ScrollViewer Background="GreenYellow" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible" Name="layoutRoot">
Canvas Width="1024" Height="768">
dataInput:Label Height="50" Name="label1" Width="100" Canvas.Left="540" Canvas.Top="131" Content="aeeeeeeee" />
Button Canvas.Left="12" Canvas.Top="131" Content="Button" Height="23" Name="button1" Width="75" />
Button Canvas.Left="937" Canvas.Top="147" Content="Button" Height="23" Name="button2" Width="75" />
Button Canvas.Left="510" Canvas.Top="21" Content="Button" Height="23" Name="button3" Width="75" />
Button Canvas.Left="482" Canvas.Top="550" Content="Button" Height="23" Name="button4" Width="75" />
/Canvas>
/ScrollViewer>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.