I made the mistake of using the SelectionChange event on a textbox while implementing some filtering on a DataGrid. What happened, when using SelectionChanged, was that each time the textbox received focus I was executing the filter. Even initially when there was nothing to filter. My logic was checking if the contents of the textbox […]
Read More →Tags: WPF
How to add a watermark to a textbox using WPF
Some time ago I had to implement a search box which filtered a result set in a DataGrid. It was a pretty straight forward exercise. However, it took some time to find a good example and change it into what I needed. Basically, what needs to be done is to add a TextBlock and a […]
Read More →Adding images to a Tree View in WPF using C#
Like I’ve said before, once you find what your looking for, it is wasy to find examples about how to use and implement it. I had this again while trying to add images to a treeview. The term I was looking for, while trying to find a solution was ValueConverter. In this solution I will […]
Read More →WPF DataGrid rendering is very slow
I was developing a WPF application that contained a DataGrid like so many times in the past. However, this time it was taking 20-30 seconds for the DataGrid to render. I checked the query execution speed. I was building the DataTable dynamically, but I checked the speed of that too and it was fast as […]
Read More →Disable navigation buttons and navigation history within a WPF Navigation Page program
The Navigation functionality of WPF is pretty cool. It lets the developer create a wizard like program which walks the user through a number of consecutive steps from start to finish. All of which happens within a single window, similar to a web browser, but it’s a desktop program. When implementing the WPF Navigation program […]
Read More →Expand first level of treeview item or node using WPF
If you recall in a previous article I created a treeview class with checkboxes here. I expanded on that later to include images here. I realized that I had set the IsExpanded property of the treeview within a setter for my treeview resources with a value of True. This meant that all nodes within the […]
Read More →Validating time using a masked textbox within a WPF window using C#
This is unfortunately more of a hack than a solution, but I thought I would share it any way. I had the situation where I needed to validate the entered time into a masked textbox. The masked textbox is a Windows Form control, but I hosted it within a WPF window using the WIndowsFormsHost element. […]
Read More →How to clear the data from a DataGrid using WPF in C#
I implemented some filtering into one of my DataGrids which required that a reset the initial result set. With a single line of code you can empty out the contents of the DataGrid. datagridResults.ItemsSource = null; Once I reset the contents to empty, I could then add the filtered content back into the DataGrid using […]
Read More →How to hide a DataGrid column in WPF using C#
In a situation where I have a DataGrid which is being bound to a List of a specific class and the DataGrid has AutoGenerateColumns set to true, I found myself needing a way to hide some of the columns which I did not want to present to a user. Below is an example of binding […]
Read More →How to capture double click event in Data Grid row using WPF and C#
There are a number of name differences between a windows form and a WPF program. For example, in a windows form program the event which is triggered when a user double-clicks on a data grid is called Doubleclick. The event in a WPF program is called MouseDoubleClick. Therefore the way to implement, program or add […]
Read More →