Skip to content

Posts tagged ‘WPF’

19
Feb

Open Source WPF Chess Example Coming Soon

WPFChess

I worked on this Chess program for another project. I had started by looking at numerous available chess programs written in C# and using WPF, but alas did not find anything I felt was up to par as a basis for what I needed. They either made the chess/UI logic really complicated or had it tightly integrated or didn’t use WPF strengths.

So, I put this project together to use proper WPF data separation techniques through data binding and templates as well as using a MEF back-end to give me some flexibility with the piece creation (my project used this a bit more intensively, but I wanted to simplify the example that I release for demonstration). It just cuts to the chase.

I’m just adding some more comments and cleaning up the code a bit and hope to have it posted by the end of the month.

10
Aug

WPF DataGrid Dilemma: Add Column to Bound DataTable

Well after many hours of being stumped and perusing the web; I finally have a solution to my dilemma surrounding the WPF DataGrid.

It seemed like a simple problem: Bind a DataGrid to a DataTable and have it update all it’s contents both ways. Getting the initial content worked like a charm, but then trying to add a new column to add new data wasn’t working at all. It was a nightmare and I any example I found just stopped at loading initial data in.

It turns out that while the DataTable behind is happy to update itself and other things bound to it will update their collections, even with AutoGenerateColumns set to true, the DataGrid just happily ignores the new column and doesn’t display a thing.

The solution I finally came upon requires that you create your own column on the DataGrid to bind back to the column added in the DataTable.

Read moreRead more