Tag: wpf

Excel文档内容到webservice

我有一个wpf员工创build窗口,我可以在其中创build名字,姓氏等基本信息,这将在我的REST Web服务中创build员工。 一个例子: 客户端: private void CreateStaffMember_Click(object sender, RoutedEventArgs e) { string uri = "http://localhost:8001/Service/Staff"; StringBuilder sb = new StringBuilder(); sb.Append("<Staff>"); sb.AppendLine("<FirstName>" + this.textBox1.Text + "</FirstName>"); sb.AppendLine("<LastName>" + this.textBox2.Text + "</LastName>"); sb.AppendLine("<Password>" + this.passwordBox1.Password + "</Password>"); sb.AppendLine("</Staff>"); string NewStudent = sb.ToString(); byte[] arr = Encoding.UTF8.GetBytes(NewStudent); HttpWebRequest req = (HttpWebRequest)WebRequest.Create(uri); req.Method = "POST"; req.ContentType = "application/xml"; […]

从MS Excel加载项WPF无模式对话框

从WinForms窗口启动的WPF表单显示为所有文本框在作为无模式对话框启动时都是不可编辑的。 我用ElementHost.EnableModelessKeyboardInterop来解决这个问题,它在那里工作。 我也作为一个加载项从MS Excel中打开相同的WPF UI。 EnableModelessKeyboardInterop黑客无法在那里工作。 每当我尝试编辑我的WPF文本框,焦点转移到Excel和键盘input呈现在Excel而不是我的WPF文本框。 有想法该怎么解决这个吗? PS – 这是继续我的早先的问题SO: WPF无模式对话框呈现文本框不可编辑

如何从数据表导出到Excel文件在WPF c#

我有一个数据表,并希望它将其导出到Excel文件,这是一个WPF应用程序,所有的解决scheme,我已经find了Web应用程序的asp.net请帮助…

在单元格中的Excel图像

如何将图像(图像types)插入到Excel工作表中的特定单元格中 taperSheet = (Microsoft.Office.Interop.Excel.Worksheet)excelSheets.get_Item("Taper"); Microsoft.Office.Interop.Excel.Range cell = GetMyPictureCELL(taperSheet); Image myImage = new Image(); RenderTargetBitmap bmp; bmp = new RenderTargetBitmap((int)this.Width, (int)this.Height, 96, 96, PixelFormats.Pbgra32); bmp.Render(myViewPort); myImage.Source = bmp; myImage.Stretch = Stretch.Uniform; 现在 ? 我希望 cell.Add(myImage) 但是我认为这并不容易。 /斯特凡 感谢您的投入doitgood 以下代码适用于我 在我的情况下,我的图像源是一个视口(myViewPort)图像的位置由单元确定 try { Image myImage = new Image(); RenderTargetBitmap bmp; PngBitmapEncoder encoder; string fileName; System.IO.Stream stream; object […]

Excel 2013崩溃

我试图将Excel 2013embedded到WPF应用程序中。 问题是,当我在以下代码中调用SetWindowLongPtr时,Excel 2013立即崩溃。 我挖了它,发现如果我注释掉WS.CHILD风格,它工作正常,但Excel表变成只读,这不是我想要的。 相同的代码与Excel 2010工作正常。 Excel.Application _excelApp; IntPtr _wrappedApplicationHandle; Int64 lngStyle; Int64 lExStyle; private void Button_Click_1(object sender, RoutedEventArgs e) { _excelApp = new Excel.Application() { Visible = true, DisplayFormulaBar = true, }; _wrappedApplicationHandle = new IntPtr( _excelApp.Hwnd); lngStyle = GetWindowLongPtr(_wrappedApplicationHandle, (int)GWL.STYLE).ToInt64(); lngStyle &= ~(int)WS.CAPTION; lngStyle &= ~(int)WS.SIZEBOX; lngStyle |= (int)WS.MAXIMIZE; lngStyle |= (int)WS.CHILD; […]

如何在WPF中debugging绑定

我有一个VS2008,C#WPF,Excel AddIn; 在某些情况下,我的插件引发exception A first chance exception of type 'System.InvalidOperationException' occurred in PresentationFramework.dll A first chance exception of type 'System.NullReferenceException' occurred in PresentationFramework.dll 但我找不到exception来自哪里。 我知道这是B / C数据绑定。 但无法find在哪里。 每次我介入,VS跟踪执行无错误的方法,然后,exception抛出,但没有线索的代码行。 我一直在苦苦挣扎,无法取得进展。 请帮忙。 谢谢 编辑,这是太长,以适应评论。 所以我只是把xaml文件放在这里。 抛出exception的@xmal文件。 DataGridComboBoxColumn引发exception <UserControl x:Class="View.BasketView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:dg="http://schemas.microsoft.com/wpf/2008/toolkit" > <UserControl.Resources> <sharedC:FunctionToHiddenVisibility x:Key="enumSRToVis"/> <sharedC:FunctionToHiddenVisibility x:Key="enumCSToVis"/> <Style x:Key="DataGridRowStyle" TargetType="{x:Type dg:DataGridRow}"> <Style.Triggers> <Trigger Property="AlternationIndex" Value="1" […]