DCSIMG
DataBinding - David Sackstein's Blog

Browse by Tags

All Tags » DataBinding (RSS)

How to Bind to the Index of a Collection in WPF by David Sackstein

Let's say you have a customer class and you are binding a DataGrid to a collection of customers. You would like the index of the customer in the collection to appear in the first column, like so: One way to do this might be to add an Index property to the Customer class and bind to that. I prefer not to go that way because it would pollute our business layer with presentation layer constraints. Solution Here is a different approach using a MultiBinding. You can download the source code for this...
תגים:, ,

Hierarchical Grid with WPF by David Sackstein

A TreeView handles hierarchical data well, and a DataGrid handles tabular data. But what about hierarchical tabular data? A simple example of such a source is a System.IO.DirectoryInfo. Each item can have zero or more children of the same type, enumerated by EnumerateDirectories. I would like to have it displayed like this: Solution You can download the source code for this solution here . The inspiration for this solution came from Delay's Blog by David Anson. I think David's idea of measuring...

TreeView DataBinding and The Composite Pattern by David Sackstein

In the previous post I demonstrated use of the HierarchicalDataTemplate to style nodes based on the type of the object that they are bound to. That declarative recursion gets you true separation between data and presentation. In this post, I will show how I made use of the Composite Pattern , INotifyPropertyChanged and BindingSource<T> to implement objects for DataBinding with the TreeView. In the next post I will show how I used LINQ to XML to read the data from an XML file. The Composite...

Aggregate CheckBox for DataGridCheckBoxColumn (Part 3) by David Sackstein

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...
תגים:, ,

Aggregate CheckBox for DataGridCheckBoxColumn (Part 2) by David Sackstein

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...
תגים:, ,
Powered by Community Server (Commercial Edition), by Telligent Systems