behind when using new CSPROJ format

I've created a WPF application using the new CSPROJ format in Visual Studio 2017. By setting the LanguageTargets, setting the generator for XAML files, setting the build action for App.Xaml, and forcing the debug executable I can successfully build and run the application. However, I have an issue in that the code editor does not recognize any controls placed in the XAML, so I ge

在使用新的CSPROJ格式后面

我已经在Visual Studio 2017中使用新的CSPROJ格式创建了一个WPF应用程序。 通过 设置LanguageTargets, 为XAML文件设置生成器, 为App.Xaml设置构建操作, 并强制调试可执行文件 我可以成功构建和运行应用程序。 但是,我遇到了一个问题,即代码编辑器无法识别放置在XAML中的任何控件,所以在编辑器中出现错误的错误并且没有智能感知。 重现步骤 启动VS 2017 创建一个新的“WPF应用程序(.NET Framework)”C#

Not able to deserialize Lazy object

I want to Serialize and DeSerialize an object which contains a Lazy Collection of some custom objects. Normally everything works perfectly fine but, if namespaces of classes used for serialization are changed, then this issue occurs. I have written a SerializationBinder to point to right classes while deserializing. But for some reason, I am not getting deserialized values. Following code

无法反序列化Lazy对象

我想Serialize和DeSerialize包含一些自定义对象的Lazy Collection的对象。 通常情况下,一切正常,但如果用于序列化的类的名称空间发生更改,则会发生此问题。 我写了一个SerializationBinder来反SerializationBinder时指向正确的类。 但由于某种原因,我没有获得反序列化的值。 下面的代码片段解释了我所得到的问题; 用于序列化的类: namespace ConsoleApplication14 { [Serializable] public class MyInnerC

Speeding Up C#

This is really two questions, but they are so similar, and to keep it simple, I figured I'd just roll them together: Firstly : Given an established C# project, what are some decent ways to speed it up beyond just plain in-code optimization? Secondly : When writing a program from scratch in C#, what are some good ways to greatly improve performance? Please stay away from general optimiza

加速C#

这实际上是两个问题,但它们非常相似,为了简单起见,我想我会把它们放在一起: 首先 :给定一个已经建立的C#项目,有什么体面的方法可以加速它不仅仅是简单的代码内优化? 其次 :在C#中从头开始编写程序时,有什么方法可以大大提高性能? 请远离一般优化技术,除非它们是C#特定的。 之前已经有人要求使用Python,Perl和Java。 离开我的头顶: 用普通对象替换容器类的非泛型变体 减少拳击/拆箱。 具体而言,

WPF CallMethodAction doesn't work in Drop, DragOver, DragEnter event

I used MVVM for my wpf project, and want to move the event( Drop, DragOver, DragEnter) to my viewmodel. I used the event in the grid, but no matter how I set the TargetObject or other property, the method won't be execute. However I made another project to reproduce the situation. Here is the code: XAML <Window x:Class="WpfApplication2.MainWindow" .

WPF CallMethodAction在Drop,DragOver和DragEnter事件中不起作用

我为我的wpf项目使用了MVVM,并且想要将事件(Drop,DragOver,DragEnter)移动到我的viewmodel中。 我在网格中使用了事件,但不管我如何设置TargetObject或其他属性,该方法都不会执行。 不过,我做了另一个项目来重现这种情况。 代码如下: XAML <Window x:Class="WpfApplication2.MainWindow" . . . Title="MainWindow" Height="350" Width="525">

WPF mouse events update performance

I have a 3D rendering application using WPF for UI. The rendering itself is done in native code, but the interaction is from WPF. Now, I've seen that the mouse events from WPF are fired at extremely irregular intervals, and in some cases I never get any events at all. This seems to be tied to how much cpu the application is using. By using low-level Win32 GetCursorPos and similar method

WPF鼠标事件更新性能

我有一个使用WPF用于UI的3D渲染应用程序。 渲染本身是用本地代码完成的,但交互来自WPF。 现在,我已经看到WPF的鼠标事件以非常不规则的间隔被触发,并且在某些情况下,我从来没有得到任何事件。 这似乎与应用程序使用的CPU数量有关。 通过使用低级别的Win32 GetCursorPos和类似的方法,我可以获得更好的响应,但这与WPF UI元素交互混淆。 有没有办法控制WPF消息处理循环的优先级,或者通过其他方法确保我获得我需要的鼠

Raise Event from UserControl ViewModel

I have a WPF application that uses MVVM The MainWindowViewModel has references to other ViewModels like so:- this.SearchJobVM = new SearchJobViewModel(); this.JobDetailsVM = new JobDetailsViewModel(); this.JobEditVM = new JobEditViewModel(); I have a Label on the MainWindow called StatusMessage which is bound to a string property on the MainWindowViewModel

从UserControl ViewModel引发事件

我有一个使用MVVM的WPF应用程序 MainWindowViewModel具有对其他ViewModels的引用,如下所示: - this.SearchJobVM = new SearchJobViewModel(); this.JobDetailsVM = new JobDetailsViewModel(); this.JobEditVM = new JobEditViewModel(); 我在MainWindow上有一个名为StatusMessage的标签,它绑定到MainWindowViewModel上的字符串属性 我想要更新以更改任何其他视图模型上的此消息

Simple login to an application

I'm continuing to learn WPF, and focusing on MVVM at the moment and using Karl Shifflett's "MVVM In a Box" tutorial. But have a question about sharing data between views/viewmodels and how it updates the view on the screen. ps I haven't covered IOC's yet. Below is a screenshot of my MainWindow in a test application. Its split into 3 sections (views), a header, a sli

简单登录到应用程序

我正在继续学习WPF,并且专注于MVVM,并使用Karl Shifflett的“MVVM In a Box”教程。 但是有一个关于在views / viewmodels之间共享数据的问题,以及它如何更新屏幕上的视图。 ps我还没有涉及国际奥委会的。 以下是我的MainWindow在测试应用程序中的截图。 它分为3个部分(视图),一个标题,一个带按钮的滑动面板,其余部分作为应用程序的主视图。 该应用程序的目的很简单,即登录到应用程序。 在成功登录时,登录视图应该

Async Task.WhenAll with timeout

Is there a way in the new async dotnet 4.5 library to set a timeout on the Task.WhenAll method. I want to fetch several sources and stop after say 5 seconds and skip the sources that weren't finished. You could combine the resulting Task with a Task.Delay() using Task.WhenAny() : await Task.WhenAny(Task.WhenAll(tasks), Task.Delay(timeout)); If you want to harvest completed tasks in case

异步Task.WhenAll超时

在新的异步dotnet 4.5库中有一种方法可以在Task.WhenAll方法上设置超时。 我想要获取多个源并在5秒后停止并跳过未完成的源。 您可以使用Task.WhenAny()将生成的Task与Task.Delay()使用: await Task.WhenAny(Task.WhenAll(tasks), Task.Delay(timeout)); 如果您想在超时情况下收获完成的任务: var completedResults = tasks .Where(t => t.Status == TaskStatus.RanToCompletion) .Select(t => t.Result) .T

Why is the async CTP performing poorly?

I don't really understand why await and async don't improve the performance of my code here like they're supposed to. Though skeptical, I thought the compiler was supposed to rewrite my method so that the downloads were done in parallel... but it seems like that's not actually happening. (I do realize that await and async do not create separate threads; however, the OS should

为什么异步CTP表现不佳?

我不明白为什么await和async不会像他们应该那样改善我的代码的性能。 尽管持怀疑态度,但我认为编译器应该重写我的方法,以便下载可以并行进行......但似乎并未实际发生。 (我不知道, await和async不创建单独的线程;但是,操作系统应该做在parallal的下载,并在原来的线程中调用回我的代码-不应该吗?) 我是否使用async并await不当? 什么是使用它们的正确方法? 码: using System; using System.Net; using System

What happens to an `awaiting` thread in C# Async CTP?

I've been reading about the new async await keyword and it sounds awesome, but there is one key question I haven't been able to find the answer for in any of the intro videos I've watched so far (I also read the whitepaper a while back). Suppose I have a call to await in a nested function on the main UI thread. What happens to the thread at this point? Does control go back to the

C#异步CTP中的“等待”线程会发生什么?

我一直在阅读关于新的async await关键字,这听起来很棒,但是在迄今为止我看过的任何介绍视频中,我还没有找到答案的关键问题(我也读过一会儿白皮书)。 假设我有一个调用来await主UI线程上的嵌套函数。 此时线程会发生什么? 控制是否回到消息循环,并且UI线程可以自由处理其他输入? 等待完成的任务完成后,整个堆栈是否会被推送到消息队列中,从而控制将通过每个嵌套函数返回,还是完全发生在这里? 其次(当我引起