eagleboost Blog

梦想做大侠

Unity Container (1) Injecting type aware ILogger

Advanced Unity Container usages

Many large scale applications adopt the concept of IoC, it’s especially useful in terms of component de-coupling and writing reusable codes. Among all of the IoC containers on the mar...

Handle Task Exceptions Gracefully

优雅地处理Task中的异常

1. The Problem When using Tasks on .net platform, exception handling is one of most common problems for developers to deal with. In this blog, however, instead of talking about topics l...

AsyncTaskExecutor

A reusable GUI component for Task execution

1. The Problem During application development we often see some patterns can be reused. For example, in a WPF application we send some async calls to a background Task to execute withou...

ToolTipBinding

ToolTip Binding with StringFormat

1. The problem ToolTip binding is one of the common problems of WPF applications. For example, the binding source has a Int32 property Number, its value can be positive or negative, bas...

关闭 'Resource not found' 警告

Turn off 'Resource not found' trace log

1. The problem When working with WPF applications, it’s common to see logs like below in the Output window of the debugger (Visual Studio, Rider, etc). 1 System.Windows.ResourceDiction...

EnabledStateBinding

WPF Best Practices

1. 问题 UI编程中的一个常见场景是根据上下文把某些控件设置为不可用状态,比如这个并不恰当的例子。 在M-V-VM的语境下最简单的实现方法是在ViewModel中添加一个与所绑定的值属性对应的属性,比如TextBox的Text属性绑定到ViewModel的Name属性,那么TextBox的IsEnabled属性就绑定到ViewModel的IsNameEnabled属性,如下所示: ...

DispatcherTaskWaiter

ConfigureAwait(Dispatcher)

1. The problem The concept of the [DispatcherWaiter] presented in my previous post Convert BeginInvoke to async/await solves the problem of switching back to GUI thread after await some...

M-V-VM下实现数据项的选择(三)

WPF Best Practices

1. RadioSelectionContainer应用 互斥单选是该系列第一篇提到的痛点之一,通常基于RadioButton的做法代码略显累赘。使用上一篇提到的RadioSelectionContainer则可以非常优雅地实现。 假设有如下例子,ListBox根据ItemsSource生成多个互斥的RadioButton,上方的TextBlock显示当前选中的项。 对应的XAML...

从BeginInvoke到async/await

Convert BeginInvoke to async/await

The problem Dispatcher.BeginInvoke is one of the useful functions that is widely used in WPF applications. It’s often used in two scenarios: Cross thread scheduling - When some calc...

M-V-VM下实现数据项的选择(二)

WPF Best Practices

1. ISelectionContainer接口 先解释一下上一篇结尾定义的ISelectionContainer接口。 该接口提供了支持数据项选择的所有功能。SelectedItems很简单,用于返回当前选中的所有数据项。Clear/Select/Unselect几个方法用于改变选中列表,比如当界面控件的SelectionChanged事件发生时可以调用这几个方法把数据传递到ViewM...