Tag: wpf

使用CEFSharp Web浏览器的WPF应用程序在clickonce版本中崩溃

我有一个简单的WPF应用程序,它可以在调试中正常工作,但是当我尝试加载CEFSharp Web浏览器时,会发出clickonce释放它的崩溃 我有一个登录页面,用户然后点击打开浏览器一旦点击我得到以下错误 PresentationFramework.dll中出现未处理的“System.Windows.Markup.XamlParseException”类型exception 附加信息:调用与指定的绑定约束匹配的类型“MyProject.Views.CefSharpWebBrowserUserControl”上的构造函数引发exception。 > > > > > > > > 例外:无法创建“CefSharpWebBrowserUserControl”的实例。 TargetInvocationException:调用目标抛出exception。 FileNotFoundException:无法加载文件或程序集’CefSharp.Core,Version = 45.0.0.0,Culture = neutral,PublicKeyToken = 40c4b6fc221f4138’或其依赖项之一。 该系统找不到指定的文件。 代码背后 public partial class CefSharpWebBrowserUserControl : UserControl { public CefSharpWebBrowserUserControl() { InitializeComponent(); var settings = new CefSettings(); settings.PackLoadingDisabled = true; WebBrowser = new ChromiumWebBrowser(); WebBrowser.Address = “www.google.com”; BrowserGrid.Children.Add(WebBrowser); } public ChromiumWebBrowser WebBrowser […]

是否可以在扩展WPF工具包的Busyindicator中更改繁忙的动画?

是否可以在扩展WPF工具包的Busyindicator中更改繁忙的动画? 特别是,我想将其更改为.gif动画。

如何在ShowDialog()阻塞调用之前注册消息处理程序?

我正在使用Messenger类来在视图模型之间发送数据。 有一个AppView在内容控件中托管两个主视图,到目前为止,以这种方式发送/接收数据没有任何问题。 问题: 现在我添加了一个ProductView ,它显示了一个单独的AppView对话框。 但是当我调用Messenger.Default.Send(SelectedProduct); 在调用.ShowDetailDialog()之后,这会阻止Send代码调用,直到对话框关闭。 我试着反过来,首先调用Send代码,然后打开对话框。 但这意味着接收VM中的消息处理程序在发送消息之前不会及时注册。 有没有人知道一个解决方案,以防止对话框阻止发送呼叫? 或者在发送消息和显示对话框之前注册ProductVM消息处理程序? 以下是相关课程的摘要: CustomerOrdersVM(发送代码): private void EditOrder(object obj) { _dialogService.ShowDetailDialog(); Messenger.Default.Send(SelectedProduct); } ProductVM(接收代码): public ProductViewModel() { Messenger.Default.Register(this, OnSelectedProductReceived); } DialogService: class DialogService : IDialogService { Window productView = null; public DialogService() { } public void ShowDetailDialog() { productView = new ProductView(); productView.ShowDialog(); } } AppVM(主VM已注册,ProductVM独立于此VM): public […]

WPF拖放 – 从DragEventArgs获取原始源信息

我正在尝试使用MVVM编写拖放function,这将允许我将PersonModel对象从一个ListView拖到另一个。 这几乎可以工作,但我需要能够从DragEventArgs获取源ListView的ItemsSource,我无法弄清楚如何做。 private void OnHandleDrop(DragEventArgs e) { if (e.Data != null && e.Data.GetDataPresent(“myFormat”)) { var person = e.Data.GetData(“myFormat”) as PersonModel; //Gets the ItemsSource of the source ListView .. //Gets the ItemsSource of the target ListView and Adds the person to it ((ObservableCollection)(((ListView)e.Source).ItemsSource)).Add(person); } } 任何帮助将不胜感激。 谢谢!

SaveFileDialog上的DialogResult.OK不起作用

我尝试,当我在SaveFileDialog按保存时,我做了一些事情。 我尝试修复但总是出错。 SaveFileDialog dlg2 = new SaveFileDialog(); dlg2.Filter = “xml | *.xml”; dlg2.DefaultExt = “xml”; dlg2.ShowDialog(); if (dlg2.ShowDialog() == DialogResult.OK) {….} 但我有错误 – 这说: 错误: ‘System.Nullable’不包含’OK’的定义,并且没有扩展方法’OK’可以找到接受类型’System.Nullable’的第一个参数(你是否缺少using指令或汇编引用?) 我尝试修复此代码: DialogResult result = dlg2.ShowDialog(); //here is error again if (result == DialogResult.OK) {….} 现在错误是在DialogResult上说: ‘System.Windows.Window.DialogResult’是’属性’但是像’类型’一样使用

wpf – 我可以在wpf中使用System.Drawing吗?

我将图像保存在数据库中。 ..但如何从数据库中检索该图像..当我尝试使用system.drawing ..它显示错误..一些ppl说我不能在wpf中使用system.drwa ..甚至不是dll文件.. 我的代码是 private void btnShow_Click(object sender, RoutedEventArgs e) { DataTable dt2 = reqBll.SelectImage().Tables[0]; byte[] data = (byte[])dt2.Rows[0][1]; MemoryStream strm = new MemoryStream(); strm.Write(data, 0, data.Length); strm.Position = 0; System.Drawing.Image img = System.Drawing.Image.FromStream(strm); BitmapImage bi = new BitmapImage(); bi.BeginInit(); MemoryStream ms = new MemoryStream(); img.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp); ms.Seek(0, SeekOrigin.Begin); bi.StreamSource = ms; bi.EndInit(); ImgBox.Source […]

无法在WPF中将数据插入本地数据库

在一个项目中,我有一个本地数据库,(我使用datagrid来查看数据),但问题是当我使用插入查询插入数据库时​​,插入不持久,即当我重新运行应用程序时,数据库未更改,更改未反映在数据库视图中(Visual Studio中的视图表数据)。 插入查询是: string dbCon = new System.IO.FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).DirectoryName + “\\MyDatabase.sdf”; SqlCeConnection dbconnection = new SqlCeConnection(“datasource=” + dbCon); dbconnection.Open(); String Insert = “insert into MainTable(LineID,Date,Connection_Type) Values(‘5′,’5/8/2012′,’commercial’)”; SqlCeCommand cmd = new SqlCeCommand(Insert, dbconnection); //// Execute the command cmd.ExecuteNonQuery(); dbconnection.Close(); 现在,当此代码运行时,数据网格会更新,但更改不是永久性的。 我做错了什么? 我正在使用Visual Studio 2010 Ultimate和Windows 7

为什么Thread.Join()挂起,即使线程中的方法已经返回?

我有一个WPF应用程序,它使用一些库代码进行身份validation,需要在单线程单元线程中运行。 我的方法是生成一个单独的线程来获取身份validation对象,阻塞直到线程返回然后继续执行。 但是,在某些情况下,我的应用程序挂起在Thread.Join()上,即使线程方法已返回。 public static ClaimsAuthenticationResult GetClientContextAndCookieCollection(string siteUrl, out CookieCollection cookieResult) { ClaimsAuthenticationResult authResult = new ClaimsAuthenticationResult(); // Authentication module needs to run in single-thread apartment state because it uses // COM library calls where this is required Thread authenticationThread = new Thread(new ThreadStart(threadMethod)); authenticationThread.SetApartmentState(ApartmentState.STA); authenticationThread.Start(); // Block until thread completion authenticationThread.Join(); // Application hangs […]

WPF:如何使自定义模式对话框闪烁?

通常,当您打开modal dialog并尝试单击它的父窗口时,modal dialog的标题栏会闪烁。 在WPF中创建自定义,无边框,无边框的窗口时,您将失去所有这些function,并且必须自己重建它。 我看起来高低,因为我的生活无法弄清楚如何让我的模态窗口闪烁。 虽然它仍然会发出哔哔声…… 我想我将不得不在WndProc中观察一些我必须处理的事件,但我无法弄清楚哪个事件或如何做到这一点。 我已经尝试观察窗口更改和窗口更改事件以及WM_ACTIVATE事件无济于事。 我确定我只是遗漏了一些简单的东西,但我会很感激你的帮助。 谢谢!

WPF TreeViewItem切换按钮可见性

我遇到了一个问题,我希望有人可以帮我解决。 我遇到过一个案例,我的节点包含一组可见性设置为false的子节点。 我希望我可以禁用TreeViewItem旁边的切换箭头,如果它的所有子项都是不可见的。 这可能吗? 这是一个例子: 我如何获得Cold Drinks TreeViewItem来隐藏切换箭头?