Skip to main content

WPF – MVVM – Get filtered values from a GridView

The goal of this article is to show how to get the filtered items from a GridView (here we will use Telerik RadGridView, but it should be the same for any Grid). This case is really useful if you need to apply some calculation on a filtered subset of the Data you’re displaying, while you’re […]

WPF – Add a Watermark to a native WPF TextBox

This is how to add a Watermark to a native WPF TextBox without using a control from another toolkit.  The concept is to create a Style which will add a new property (called Tag) for your TextBoxes. The content of this Tag will be the watermark. And it will manage the events like if you […]

WPF – MVVM – Proxy Binding

Here the purpose is to be able to bind a Command on a Button which is under 2 levels of ItemsControl without using the “Ancestor” stuff. So the classic way of doing this: the following should work : <TextBlock Text=”{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.Client.Name}” /> But we can do something better and more readable. […]

WPF MultiBinding

WPF MultiBinding

In WPF, it’s pretty common to display differenct properties of an object as if there where one. Typycally, I have a User, which contains a FirstName and a LastName and I want them both to be displayed as one. <TextBlock> <TextBlock.Text> <MultiBinding StringFormat=”{}{0} ({1})” > <Binding Path=”User.FirstName”></Binding> <Binding Path=”User.LastName”></Binding> </MultiBinding> </TextBlock.Text> </TextBlock> Enjoy!

SaveFileDiaglog

Here is a simple example of how to use the native SaveFileDialog. var sfd = new SaveFileDialog { Filter = “PDF Documents|*.pdf”, DefaultExt = “.pdf”, FileName = “converted.pdf” }; // Show save file dialog box var result = sfd.ShowDialog(); // Get the location of the file if (result != true) return; var fileName = sfd.FileName; […]