WPF app crashes after migration to TFS 2017

Recently we’ve migrated our projects repository from TFS 2010 to TFS 2017. Unfortunately it soon turned out that WPF projects doesn’t cooperate with new TFS. Well, actually they did cooperate well with TFS but didn’t cooperate with the User. The build process went well with no warnings and the application was properly deployed. However after the app was deployed and we wanted t…

By Mirek on (tags: AssemblyVersion, msbuild, resource dictionary, TFS 2017, WPF, XAML, categories: architecture, tools)

Pivot grid in WPF

Today I am going to show you how easy to achieve a pivot scrolling in wpf using scroll viewers and scroll bars. What we are going to achieve is presented on following picture The center and top part can be scrolled horizontally using bottom scroll bar (red rectangle). From the other side the vertical scroll bar affects center and left side part (orange rectangle). So when we sc…

By Mirek on (tags: pivot grid, WPF, categories: code)

Why does the binding get updated only once in WPF user control?

Recently I struggled on my user control trying to make the dependency property be updated when I change the source of the binding. That confirmed my belief that WPF does not forgive any single developer’s mistake. For the sake of this post I simplified the code. The code of the user control was something like this And the xaml, here I use this control was like this Simple, noth…

By Mirek on (tags: dependency property, user control, WPF, categories: code)

Movable rows in WPF DataGrid

DataGrid control in WPF is a rich table structured control, which is perfect for displaying any kind of data in table like format. The one think about DataGrid it always lack, is a possibility to easily change the order of rows. It is not even about drag and drop of rows and items from and into the DataGrid , but simply rearrange existing rows in DataGrid control. It this post …

By Mirek on (tags: Attached property, DataGrid, WPF, categories: code)

WPF CollectionView can leak memory

A time ago I wrote about using collection views in WPF to achieve different looks at the same source collection. By creating different instances of ListCollectionView we could have the collection displayed in different sorting, ordering and grouping shape. Unfortunately there is small trap when using collection views. CollectionView class instantiated with a source collection t…

By Mirek on (tags: CollectionView, memory leak, WPF, categories: code)

Memory leak using PropertyDescriptor AddValueChanged

Recently I found out that my attached property, which I am using to modify the dependency property of one of my controls, causes a memory leak. Finally it turned out that it is not the attached property, but the titled method of PropertyDescriptor I have used in my code. The AddValueChanged method allows to monitor changes on any dependency property of a component. In my case I…

By Mirek on (tags: memory leak, WPF, categories: code)

Restyle your window

Until recently, creating a custom window style in Windows Presentation Foundation was quite a challenging task. You had to implement the window’s behavior from scratch. Resizing, moving and all other typically window related functionality had to be reinvented and reimplemented just because you wanted the window header bar to look different. You could also (and still can if you …

By Mirek on (tags: style, WindowChrome, WPF, categories: code)

WPF– visual states in MvvM

WPF has many rich features which facilitates making a great look&feel of the application. Unfortunately many of those features are cumbersome to implement and use when we develop in a Model - View – ViewModel architecture. In this post I will try to make you more familiar with visual states and how can we use them in our MvvM application. Visual state simply defines a state…

By Mirek on (tags: behaviors, Expression Blend, Visual state, WPF, categories: code)

Handling already handled events in WPF

This is a simple trick to handle already handled routed events in WPF application. In WPF the routed events are passed down through the visual tree from the source of the event until they meet the element that can handle them. This behavior, called bubbling, is sometimes not what we expect. Imagine a situation when we have a grid and other child controls in it. We want to …

By Mirek on (tags: routed events, WPF, categories: code)

Where should I store settings of my application?

Where should I store user and application settings in my WPF application? Well, in Settings of course. Go to your WPF application properties and Settings tab. If there is nothing there but text in the middle, click on that text. This will create the Settings file in your project. Here you can add settings in the grid. The columns are: Name, Type, Scope and the Value. Name and t…

By Mirek on (tags: c#, settings, WPF, categories: architecture)