WPF MVVMLight:基于另一个DataGrid的SelectedItem更新DataGrid

使用MVVMLight开发WPF应用程序。 我的Model由一个Attribute类和一个DataSet类组成,其中一个名为Attributes的ObservableCollection Attributes 。 我的MainViewModel有一个DataSet属性。 在我的MainView ,它的DataContext设置为MainViewModel我有两个DataGrids 。 一个有它的ItemsSource绑定到DataSet.Attributes工作正常: //some DataGrid columns here 我希望第二个DataGrid基于第一个DataGrid的SelectedItem显示一些其他属性,所以我做了以下内容: 1)在MainViewModel添加了Attribute类型的SelectedAttribute属性: private Attribute selectedAttribute; public Attribute SelectedAttribute { get { return selectedAttribute; } set { if (selectedAttribute == value) { return; } selectedAttribute = value; RaisePropertyChanged(() => SelectedAttribute); } } 2)修改了我的第一个DataGrid ,将其SelectedItem绑定到SelectedAttribute : 3) Update 1将第二个DataGrid的ItemsSource设置为SelectedAttribute并创建一个绑定到SelectedAttribute的Categories属性的列,它是ObservableCollection : 4)在我的MainViewModel ,一旦填充了DataSet.Attributes ,我将SelectedAttribute设置为集合中的第一个Attribute (就像测试一样): […]

使用iTextSharp打印包含多个表的PDF

我有一份详细的打印账单,可以从各个部门提取账单明细。 我需要将它们打印在PDF上。 但是我使用了大量的选择程序,因为我必须显示很多表,所以我需要可以重用的代码。

Unity – 从另一个脚本访问脚本

我无法从“GameManager”脚本访问脚本。 也许他们彼此不认识,因为他们在不同的文件夹中? 但是,如果我尝试将脚本从一个文件夹移动到另一个子文件夹 – 所有引用都会死掉! 从头开始重新配置所有脚本真的很难。 Heres是我的GameManager所在的地方: 这是我的Gun_Controller_所在的位置: inheritance人错误: 我怎么解决这个问题? 提前致谢!

C#中对象的不同列表

我必须区分对象列表,但不仅仅是ID,因为有时两个不同的对象具有相同的ID。 我有课: public class MessageDTO { public MessageDTO(MessageDTO a) { this.MsgID = a.MsgID; this.Subject = a.Subject; this.MessageText = a.MessageText; this.ViewedDate = a.ViewedDate; this.CreatedDate = a.CreatedDate; } public int? MsgID { get; set; } public string Subject { get; set; } public string MessageText { get; set; } public System.DateTime? ViewedDate { get; set; } public […]

如何使用数字字符实体而不是问号XmlDocument.Save()到encoding =“us-ascii”?

我的目标是在不丢失Unicode字符的情况下获得XML的二进制缓冲区( MemoryStream.ToArray()将在这种情况下产生byte[] )。 我希望XML序列化程序使用数字字符引用来表示在ASCII中无效的任何内容。 到目前为止,我有: using System; using System.IO; using System.Text; using System.Xml; class Program { static void Main(string[] args) { var doc = new XmlDocument(); doc.LoadXml(““∞π””); using (var buf = new MemoryStream()) { using (var writer = new StreamWriter(buf, Encoding.ASCII)) doc.Save(writer); Console.Write(Encoding.ASCII.GetString(buf.ToArray())); } } } 上面的程序产生以下输出: $ ./ConsoleApplication2.exe ???? 我想通了如何告诉XmlDocument.Save()使用encoding=”us-ascii” -by将TextStream.Encoding设置为Encoding.ASCII TextStream.Encoding 。 文档说明The […]

通常填充不同的类成员

我正在开发一个带有几(11)个Web服务调用的Web服务应用程序。 对于每个Web服务,我需要从字符串数组中填充Soap Body,如下所示: if (aMessage[(int)DCSSCustomerUpdate_V3.Branch].ToString().Length != 0) { wsSoapBody.Branch = aMessage[(int)DCSSCustomerUpdate_V3.Branch].ToString(); } aMessage[int]是字符串数组,[int]由枚举常量定义 – 在这种情况下,它定义如下: private enum DCSSCustomerUpdate_V3 { MsgType = 0, MsgVersion = 1, WSName = 2, ReplyTo = 3, SourceSystem = 4, … } 部分类中的属性名称与枚举常量匹配,所以我想我也会传入枚举常量? 部分类在wsdl中定义如下: public partial class DCSSCustomerUpdateType { private string instIdField; private string branchField; … } 我不知道是否有一种方法可以传递部分类wsSoapBody (以及字符串数组)并循环遍历类的所有成员,分配值,而不是分别为每一个执行此操作(在11个自定义服务类中)从字符串数组? 编辑 : […]

通过Web服务正确捕获特定exception

我目前在客户端程序中使用C#.NET服务。 作为服务器设计的一部分,抛出了几个自定义exception以指示特定错误(如在任何普通桌面程序中)。 问题是Web Service捕获这些错误并将它们序列化为FaultException,并在Message字段中写入实际exception(如NoRoomsAvailableException)。 我的问题是,是否有处理这些错误的最佳做法。 我们刚刚开始研究这个问题,我们可能会做一些文本模式匹配来提取exception类型和错误消息,但这似乎是一种hacky方式,所以任何“干净”的做法都会很多赞赏。

颜色整行而不是单个单元格

我一直试图改变Compact Framework DataGrid中一行的背景颜色,但由于.NET CF上的DataGrid与其Windows Forms对应物相比有限,因此几乎没有成功。 我实现目标的唯一成功是我现在能够根据其值改变单个单元格的背景颜色。 我无法操纵我从谷歌搜索获得的代码,因为我在C#中不是那么好。 但是,这是我的代码: namespace GridColor { public delegate void CheckCellEventHandler(object sender, DataGridEnableEventArgs e); public class DataGridEnableEventArgs : EventArgs { private int _column; private int _row; private bool _meetsCriteria; public DataGridEnableEventArgs(int row, int col, bool val) { _row = row; _column = col; _meetsCriteria = val; } public int Column { […]

为什么从给定订阅者抛出时从未调用OnError回调?

请观察以下unit testing: using System; using System.Reactive.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace UnitTests { [TestClass] public class TestRx { public const int UNIT_TEST_TIMEOUT = 5000; private static IObservable GetObservable(int count = 100, int msWait = 10) { return Observable.Create(async (obs, cancellationToken) => { for (int i = 0; i { Thread.Sleep(msWait); return value; })); […]

部署网站时缺少using指令或程序集引用错误

我有一个网站,* .cs文件位于App_Code文件夹中(在我的项目中添加一个类项目时,VS2010建议我创建这个文件夹)。 我有一个default.aspx.cs文件,它使用这个类。 当我在VS2010上运行时,它运行时没有任何错误。 但是,当我通过私人托管公司在网络服务器上部署网站时。 它给了我这个错误: Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: CS0246: The type or namespace name ‘SMSAPP’ could not be found (are you missing a using […]