William Basics

Keep learning, never ending.

[WPF] How to avoid calling initial methods in the view model’s constructor

Introduction When developing a WFP application in the MVVM way, we often need to initialize such as loading data, logging, and other kinds of stuff when the view model is created. The no-brain way is to call the “initialization” method directly in the view model’s constructor while hoping the calling method never fails and finishes instantly. public class AwsomeViewModel { public AwsomeViewModel () { LoadDataFromDatabase(); } } However, To call a method that is likely to fail or costs a long time is a bad practice in any way.

[Math] - FFT By Using Math.NET Numberics

引言 快速傅里叶变换是信号处理的常用工具。当我们想要对时间域里的连续信号进行成分分析时,我们就需要通过傅里叶变换来将时间域的连续信号转化为频率

[UnitTest] -How to test a private method in C#?

引言 对于是否要测试私有方法的争论由来已久。很多人对于这个问题总是不从正面回答,反而掉过头来尝试说服提问者放弃这个想法。是的,我们虽然有很多理

[Algorithm] - C# - Join the xml nodes name by using backtracking

背景与问题介绍 XML文件,大家都很熟悉了。其中的各个节点组成了一颗“树”。 比如 <A> <B> <C/> </B> <D> <E/> </D> <F> <G/> </F> </A> “客户”要求希望开发一个程序,来通过节点

[Better code] - C# - Using Indexer

什么是Indexer? Indexer 可以帮助我们如同用索引来访问数组中的元素一样来访问自定义对象中的元素。它不仅可以帮助我们写出更流畅的代码,更提高了代

[UnitTest] - 用FluentAssertions让单元测试代码更优美

Introduction 早在2005年,Martin Fowler就提出了“fluent interface“这种编码风格(link)。我们比较熟悉的LINQ就是这”

WPF - Realtime charting by using DevExpress WPF toolkit

Realtime charting by using DevExpress WPF toolkit Realtime chart的用途十分广泛,特别是在测量领域尤为常见。 这个代码样例实现了一个realtime chart的原型,借助了DevEx

WPF - Localization on-the-fly

WPF的本地化或者说对多国语言的支持,微软官方给出的方案是借助Uid加上WPF Samples中的小工具locBaml来实现。这种方案的一个缺

WPF - Locbaml : Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly

这个error信息十分隐晦,解决方案是将LocBaml.exe拷贝到project的build目录下(xxxproject\bin\Debu

WPF - Creating Control Template Assembly

WPF - Creating Control Template Assembly 1. 新建一个WPF User Control Library project 删除 User Control1.xaml 2. Add New Item - Resource Dictionary MyButtonTemplate.xaml <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> </ResourceDictionary> 在MyButtonTemplate.xaml中加入template定义。