Tag: 元素

c#使用一种方法按元素或属性排序

我需要有时按属性排序xml文档,有时候按元素排序,具体取决于文档的类型。我如何在c#中使用一个sortBy方法来解决这个问题? 非常感谢您的帮助! 例如,我的排序键是“bookID”元素或属性,xml文件是: 100 The cat in the hat 90 another book 103 a new book 或者有时xml有以下格式: The cat in the hat another book a new book

是否有类似于hawkeye的UI检查工具与.net 4.5一起使用?

我正在使用一个针对.net 4.5的winforms应用程序,我真的需要检查UI元素。 我过去曾使用Snoop来检查wpf元素,我也遇到了Hawekeye 。 但是,看起来hawkeye与.net 4.5不兼容。 有什么工具可以给我类似的结果吗?

在c#中使用Linq匹配2个集合之间的元素

我有一个关于如何在linq中执行常见编程任务的问题。 假设我们已经做了不同的集合或数组。 我想做的是匹配数组之间的元素,如果有匹配,那么用该元素做一些事情。 例如: string[] collection1 = new string[] { “1”, “7”, “4” }; string[] collection2 = new string[] { “6”, “1”, “7” }; foreach (string str1 in collection1) { foreach (string str2 in collection2) { if (str1 == str2) { // DO SOMETHING EXCITING/// } } } 这显然可以使用上面的代码完成,但我想知道是否有一个快速和简洁的方法,你可以用LinqtoObjects做到这一点? 谢谢!

Linq To Xml问题使用XElement的方法Elements(XName)

我使用Linq To Xml时遇到问题。 一个简单的代码。 我有这个XML: aaa email@email.ext 2002-09-22 000:000000 Description for this contact sss email@email.ext 2002-09-22 000:000000 Description for this contact bbb email@email.ext 2002-09-22 000:000000 Description for this contact ccc email@email.ext 2002-09-22 000:000000 Description for this contact 我希望将每个联系人映射到对象Contact上。 为此,我使用这段代码: XDocument XDoc = XDocument.Load(System.Web.HttpRuntime.AppDomainAppPath + this.filesource); XElement XRoot = XDoc.Root; //XElement XEl = XElement.Load(this.filesource); var results […]

属性已由’FrameworkElement’注册

我正在编写两个依赖项属性,并且我在VS11的设计窗口中不断收到“[Property]已经由’FrameworkElement’注册”错误。 这是我的代码片段 public static readonly DependencyProperty IsEditingNumberProperty = DependencyProperty.Register(“IsEditingNumbers”, typeof(bool), typeof(FrameworkElement), new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.AffectsRender)); 问题似乎是第3个参数(所有者参数typeof(FrameworkElement))。 如果我将第3个参数设置为包含两个依赖项属性的类,则错误消失,但我不能直接使用xaml中的属性。 在使用之前,我必须为每个依赖属性添加所有权。 实际上,它确实正确渲染,但只有当我第一次打开它时。 第一次渲染后,它会立即给我一个例外。 在运行时,它似乎完美地工作。 我做错了什么,有没有办法摆脱这个恼人的错误? —-编辑—– 这是我的自定义类(包括2个依赖属性): public partial class EditableTextBox : UserControl { #region Dependency Properties public static readonly DependencyProperty IsEditingNumberProperty = DependencyProperty.Register(“IsEditingNumber”, typeof(bool), typeof(FrameworkElement), new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.AffectsRender)); public static readonly DependencyProperty TextProperty = DependencyProperty.Register(“Text”, typeof(string), typeof(FrameworkElement), new […]