eagleboost Blog

梦想做大侠

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...

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

WPF Best Practices

问题 用户界面由数据驱动是M-V-VM编程模式最佳实践的指标之一,其中数据项的选择同步尤为重要。数据项选择指的是ViewModel中的数据项通过数据绑定显示在界面上供用户选择,常见的场景包括互斥单选,单选及多选,选中的数据项在ViewModel和View之间应实现双向传递。 在M-V-VM的范畴内实现数据项的选择的方法很多。单选最简单,实现方法没有争议。但要正确地实现互斥单选和多选却不容...