ISynchronizedInvoke and WPF

27 באפריל 2009

I have seen a lot of discussion out there about why Dispatchers in WPF don’t implement ISynchronizedInvoke. I don’t have the answer, but I can offer you an extension method I use to simplify the synchronization of all those asynchronous events onto a window thread. Here is the extension method:     public static class Extensions     {         static public void InvokeIfRequired(this Dispatcher dispatcher, Action action)         {             if (dispatcher.CheckAccess())             {                 action();...
תגובה אחת

A Validated TextBox as a WPF UserControl

In this post I will be describing a WPF UserControl that I wrote to handle the validation of a text box. The complete source code can be downloaded here. Requirements I would like to be able to use the control like this:       <local:ValidatedTextBox x:Name="tbAnInteger">          <local:ValidatedTextBox.Text>             <Binding Path="AnInteger" Mode="TwoWay"                      UpdateSourceTrigger="PropertyChanged">                <Binding.ValidationRules>                   <local:RangeValidationRule MinValue="3" MaxValue="50" />                   <local:DivisibleValidationRule Divisor="4"/>                </Binding.ValidationRules>             </Binding> ...
אין תגובות

Aggregate CheckBox for DataGridCheckBoxColumn (Part 3)

18 באפריל 2009

I described the problem at hand in the first post in this series. In the previous post I described the high level design of the source code that demonstrates my solution. In this post, I will describe the EmployeeUserControl and summarize. You can download the complete source code for the article here. DataBinding Design First, let’s decide what should be bound to what. From the very start we made the fairly obvious decision to use an ObservableCollection<Employee> as out ItemsSource. Combined with the implementation of INotifyPropertyChanged by Employee and this simple...
תגיות: , ,
אין תגובות

Aggregate CheckBox for DataGridCheckBoxColumn (Part 2)

17 באפריל 2009

In the previous post I described the requirement to create an aggregate CheckBox for a DataGridCheckBoxColumn. You can download the source code for my solution here. In this post I describe the high level design of my solution as documentation for the source code. If you are looking for the WPF techniques themselves, you can skip to the next post (Part 3). Setting the Scene The project contains three assemblies: PresentationLayer: This is a WPF window application. UserControls: A class library that hosts the EmployeeListControl. ...
תגיות: , ,
אין תגובות

Aggregate CheckBox for DataGridCheckBoxColumn (Part 1)

It often amazes me to see how easily one can accomplish so much with WPF. And yet, let’s admit it, its can sometimes be darned hard to achieve some fairly trivial things. Here is a simple problem I worked quite hard on until I had a solution I was happy with. I boiled it down to a few specific techniques that can be reused, so I think they are worth sharing. You can download the source code for this article here. Background Let’s say you have a business object (say Employee) with a...
אין תגובות