Wpf缩放窗口内容 [英] Wpf scale window content

查看:87
本文介绍了Wpf缩放窗口内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

VS2017,.Net 4.61



我正在编写一个包含两个 WebBrowser 控件的应用程序。每个WebBRowser控件都指向同一个站点,但是位于不同的服务器上(一对pi-hole DNS服务器)。



我想扩展整个内容窗口适合窗口大小。我试过唱 Viewbox RenderTransform ,但 WebBrowser 控制忽略了缩放,但似乎仍然向网站报告控件的大小(已启用移动设备,BTW)。



什么我试过了:



0)将 WebBrowser 放入 ViewBox 容器 Stretch =Fill



1)设置 RenderTransform 用于 WebBrowser 控件



2)设置 RenderTransform 为父 Grid control

VS2017, .Net 4.61

I'm writing an app that contains two WebBrowser controls. Each WebBRowser control is pointed to the same site, but on different servers (a pair of pi-hole DNS servers).

I want to scale the content of the entire window to fit the window size. I've tried sing a Viewbox and a RenderTransform, but the WebBrowser control ignores the scaling and still appears to report the size of the control to the web site (which is mobile enabled, BTW).

What I have tried:

0) Putting the WebBrowser into a ViewBox container with Stretch="Fill"

1) Setting the RenderTransform for the WebBrowser control

2) Setting the RenderTransform for the parent Grid control

推荐答案

It缩放它能做什么:



It "scales" what it can:

<Window x:Class="WpfApp3.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfApp3"
        mc:Ignorable="d"
        Title="MainWindow"
        WindowStartupLocation="CenterScreen"
        Height="450"
        Width="800">
   <Grid>
      <Grid.ColumnDefinitions>
         <ColumnDefinition Width="*" />
         <ColumnDefinition Width="*" />
      </Grid.ColumnDefinitions>

      <WebBrowser Source="http://msdn.com" />
      <WebBrowser Grid.Column="1"
                  Source="http://msdn.com" />
   </Grid>
</Window>


嗨John,这可能会有所帮助: c# - WPF Web浏览器控件和DPI缩放 - 堆栈溢出 [ ^ ]
Hi John, this may help: c# - WPF Web Browser Control and DPI Scaling - Stack Overflow[^]


这篇关于Wpf缩放窗口内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆