ButtonChrome

Stories submitted by ButtonChrome

WPF TreeView - SelectedItem Two Way Binding(www.deanchalk.me.uk)

submitted by ButtonChromeButtonChrome(230) 8 months, 24 days ago

Because the standard WPF TreeView implementation supports Virtualization it is unable to support two way bindings on its SelectedItem property as standard. This makes sense, because with Virtualization you may not have a container (TreeViewItem) available for any particular bound data item at the time you need it (to set its IsSelected property of the TreeViewItem to ‘True’). read more...

1 comment |category: |Views: 62

tags: another

WPF – Colour Picker Widget With Attached Properties(www.deanchalk.me.uk)

submitted by ButtonChromeButtonChrome(230) 1 year, 6 months ago

We can set the colour of any WPF control that supports it, but what about being able to specifically setting individual colour channels (RED, GREEN, BLUE, ALPHA) I've seen many solutions that contain complex custom controls, but one of the key philosophies of WPF is to reuse what you already have, and change the look or extend the functionality via control templates and the dependency system. therefore, I have created a colour picker widget that uses only standard controls, and doesn't even change their control templates. Everything is accomplished via the use of attached properties, which are a very underrated tool in the WPF tookbox. read more...

add a comment |category: |Views: 21

tags: another

WPF – Loading Spinner Via MVVM and Attached Properties(www.deanchalk.me.uk)

submitted by ButtonChromeButtonChrome(230) 1 year, 6 months ago

When I used to write a lot of Ajax for ASP.NET (many years ago) I quite like the feature whereby you could disable the page and show a ‘loading spinner’ while waiting for an update in the page. This is a great feature to have in WPF, so I have created a ViewModel with a ‘loading’ switch (bool), and an attached property that creates and displays the animated spinner (for the duration of the switch flag being true) read more...

add a comment |category: |Views: 122

tags: another

WPF - Modal Controls Via DispatcherFrame (Nested Message Pumps)(www.deanchalk.me.uk)

submitted by ButtonChromeButtonChrome(230) 1 year, 6 months ago

Creating truly modal controls in WPF is very tricky, usually its achieved by de-chroming a modal window to emulate the desired result. Well you can actually interact with controls on a blocked Dispatcher thread (making them modal) by creating nested message pumps via DispatcherFrame read more...

add a comment |category: |Views: 43

tags: another

MVVM – Simple Generic<T> Event Commands With Attached Properties(www.deanchalk.me.uk)

submitted by ButtonChromeButtonChrome(230) 1 year, 6 months ago

One of the challenges of MVVM is to favour command bindings over handling routed events, as currently all event handling must happen in the ‘code behind’ file rather than the ViewModel – which breaks the pattern. There are many elaborate and highly engineered strategies that I have seen to solve this, but maybe we could use a simple attached property implementation to achieve the desired effect. Also, WPF bindings (including command bindings) don't support generics, but maybe we could use type inference to create a generic implementation. read more...

add a comment |category: |Views: 81

tags: another

LINQ - Dynamically Leverage IList<T> Functionality With VirtualList<T>(www.deanchalk.me.uk)

submitted by ButtonChromeButtonChrome(230) 1 year, 6 months ago

There are a lot of extension methods in the LINQ space that allow you to manipulate lists quickly and efficiently, but we may not always want to use an actual list to leverage the power of this functionality. read more...

add a comment |category: |Views: 13

tags: another

WPF – Using Attached Properties For Animated Data Change Notifications(www.deanchalk.me.uk)

submitted by ButtonChromeButtonChrome(230) 1 year, 6 months ago

Working in the investment banking industry, we often need to feed live (changing) market data into our WPF controls, and often there is a requirement that certain movements (in value) are highlighted briefly so as to give a strong visual representation of data changes. read more...

add a comment |category: |Views: 24

tags: another

WPF - Simple Error Notifications For Data Binding Expressions(www.deanchalk.me.uk)

submitted by ButtonChromeButtonChrome(230) 1 year, 7 months ago

One of the frustrating things about a large and complex XAML view in WPF, is that you are not often aware of errors in your data binding expressions. You may not even know there's an error, and if you do then you have to trawl through debugger outputs to try and find it. You could always use snoop, but surely theres a simpler way read more...

add a comment |category: |Views: 102

tags: another

WPF – Easy INotifyPropertyChanged Via DynamicObject Proxy(www.deanchalk.me.uk)

submitted by ButtonChromeButtonChrome(230) 1 year, 7 months ago

In the WPF/Silverlight world there are many ways to implement INotifyPropertyChanged, but few are very robust. Here's a robust solution using CLR4 dynamic objects read more...

add a comment |category: |Views: 68

tags: another

F# - Interacting With WPF Dispatcher Via F# Interactive Window(www.deanchalk.me.uk)

submitted by ButtonChromeButtonChrome(230) 1 year, 7 months ago

How To Invoke a WPF popup from the FSharp Interactive Window .. BUT .. on a seperate UI message pump, then interact with it via asynchronous delegates in FSharp Interactive (thus keeping the popup responsive on long-running tasks) read more...

add a comment |category: |Views: 49

tags: another

C# - Fast Parallel ConcurrentList<T> Implementation(www.deanchalk.me.uk)

submitted by ButtonChromeButtonChrome(230) 1 year, 7 months ago

In the new .NET 4 Task Parallel Library we already have ConcurrentBag, ConcurrentQueue, concurrentStack, ConcurrentDictionary - but where's our ConcurrentList ? This article gives a full C# implementation. read more...

add a comment |category: |Views: 109

tags: another

C# – Creating Reliable Complex Dictionary Keys Using Generic Tuples(www.deanchalk.me.uk)

submitted by ButtonChromeButtonChrome(230) 2 years ago

Complex dictionary keys require careful consideration, and a lot of work implementing correctly. However, using generic Tuples, we can solve the problem easily and reliably read more...

add a comment |category: |Views: 24

tags: another

WPF MVVM – Simple ‘MessageBox.Show’ With Action And Func(www.deanchalk.me.uk)

submitted by ButtonChromeButtonChrome(230) 2 years ago

In the MVVM world, things like message boxes (MessageBox.Show) and Dialogs (open file, save file etc), don't naturally fit. These popups are closely tied to the ‘View’ part of MVVM, but they can only really be invoked from the ‘ViewModel’ which will break the clean separation in MVVM. The solution I came up with, is to use generic Action and Func Delegates. read more...

add a comment |category: |Views: 163

tags: another

WPF – DataContext Virtualization With Paged Services(www.deanchalk.me.uk)

submitted by ButtonChromeButtonChrome(230) 2 years ago

Many WPF applications need to handle a very large data collections – maybe the users really need a million rows in their GridView control. The way we cope with this is to ‘virtualize’ the data, and have it available to your control on an ‘as needed’ basis. Most list controls in WPF (including the standard ListView/GridView) include the concept of a ‘viewport’ under the hood. A viewport is a virtual ‘window’ on the underlying data collection, which only requires the data currently being displayed – so if your collection is a million rows, and your ‘viewport’ is only 100 rows high, then you only need 100 rows (although they must be the ‘right’ rows). read more...

add a comment |category: |Views: 15

tags: another

Lightweight ‘O/R Mapping’ in F# Interactive(www.deanchalk.me.uk)

submitted by ButtonChromeButtonChrome(230) 2 years ago

Using F# Interactive to play around with data is a common scenario. However, getting standard relational data into a strongly-typed collection is necessary. Here are a few lines of code that can do it for you read more...

add a comment |category: |Views: 14

tags: another

F# And MVVM - A Simple ViewModel(www.deanchalk.me.uk)

submitted by ButtonChromeButtonChrome(230) 2 years, 1 month ago

This F# ViewModel is a very simple one, but it covers all the main bases:- It has a generic ICommand implementation for command binding It implements INotifyPropertyChanged for change notifications It has Data for binding read more...

add a comment |category: |Views: 72

tags: another