1. 前提 原本是在大屏上展示系统,系统有个功能是加载第三方的网站,第三方网站按照大屏的分辨率写死了宽高: 现需要改到小屏展示系统,而这个第三方的网站不能随着 WebBrowser 窗口的尺寸调整网站内容的尺寸. 2. 解决思路 1)加载完毕后,调用 InvokeScript 方法执行在当前加载的文档中定义的脚本函数,简单说就是调用网站的 js 方法: 2)网站未必会定义一个实现相关功能的方法,因此我们可以通过 eval 方法执行 js 代码. <Grid x:Name="wb"…
为了学习自定义控件,就想看看WPF基本元素的代码.使用到工具.NET Reflector. System.Windows.Controls 命名空间在PresentationFramework.dll中. Control Class 继承关系. Q:Where can I find System.Windows.Controls.dll and System.Windows.Controls.Data.dll ===========================================…
在WPF中DataGrid 选择事件中获取SelectedItems 报错如下 无法将类型为“System.Windows.Controls.SelectedItemCollection”的对象强制转换为类型“System.Collections.Generic.IList`1[SomeModel]”. 应该如此使用 System.Collections.IList items = (System.Collections.IList)this.dataGrid.SelectedItems;  …
wb 是 拖放在窗体上的 System.Windows.Forms.WebBrowser 在你的窗体代码中定义 SHDocVw.WebBrowser_V1 wb1; 在 你窗体的 load 事件中 加入下面的代码 wb1 = wb.ActiveXInstance as SHDocVw.WebBrowser_V1; wb1.NewWindow += wb1_NewWindow; 处理事件: void wb1_NewWindow(string URL, int Flags, string Targe…
textComBox.SelectedItem as ComboBoxItem).Content textConbox: 控件Combobox 的Name 在Combobox控件SelectionChanged事件中使用…
参考 [完美]原生JS获取浏览器版本判断--支持Edge,IE,Chrome,Firefox,Opera,Safari,以及各种使用Chrome和IE混合内核的浏览器 利用js来判断 namespace WindowsFormsApp1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); //webBrowser1.Navigate(@"C:\Users\admin\Desktop\test.…
WPF中实例化Com组件,调用组件的方法时报System.Windows.Forms.AxHost+InvalidActiveXStateException的异常 在wpf中封装Com组件时,调用组件的方法时抛出异常System.Windows.Forms.AxHost+InvalidActiveXStateException的异常. 通过网上查询发现,除了实例化com组件,还要将该对象进行初始化. 添加如下代码后 System.Windows.Controls.Grid CTSGrid = n…
WPF项目中,从Nuget搜索并下载System.Windows.Interactivity.dll,安装到项目中,并在XAML界面引入. <UserControl xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"> .... </UserControl> 在目标UI控件上添加一个鼠标右键点击弹起事件. <!-- 鼠标右键事件…
下载System.Windows.Interactivity.dll文件,并引入项目中(在VS项目的引用列表中可以看到).可在Nuget搜索System.Windows.Interactivity下载安装到项目中. XAML中使用该dll xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" <!-- TextBox控件的获得焦点.失去焦点事件 --&g…
这里使用了一个进度条来展示, 前段代码: <Window x:Class="TimerTest.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="> <Grid> <Button…