Skip to main content

WPF – Missing Underscore with Label or CheckBox

Did you ever have a missing underscore with WPF?  If you have a Label or a Checkbox containing underscores, the first underscore will not be displayed on  screen. It is called the RecognizeAccessKey. Which allows you to reach the control with you keyboard by pressing ALT and the first lettre following the first underscore.  So […]

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 […]

C# – Start any Windows application from code

To start any application by code, it pretty easy: static void Main(string[] args) { var pi = new ProcessStartInfo { FileName = “calc”, //Arguments = “…”, //RedirectStandardOutput = true, UseShellExecute = false //Allows the redirection of the ouput }; var p = Process.Start(pi); } But in that simple case, we could just do: static void […]

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!

How to connect to LocalDB in Visual Studio Server Explorer

Steps to connect LocalDB to Visual Studio Server Explorer Open command prompt Run SqlLocalDB.exe start v11.0 Run SqlLocalDB.exe info v11.0 Copy the Instance pipe name that starts with np:\… In Visual Studio select TOOLS > Connect to Database… For Server Name enter (localdb)\v11.0. If it didn’t work, use the Instance pipe name that you copied earlier. You can also use this to […]

Generate a PDF with Scryber

Today we will generate a PDF with the open source Scryber. The best way to work with Scryber is to use a template (PDFX file) for the style, the layout and the static content, then insert the dynamic content with C#. Full documentation at this link. Good example at this link. Create a new XML […]

Open a file with the default application

If you double click on a PDF file, it will be opened by the default application linked to that extension. So if Acrobad Reader is installed it will be opened with that application. In .Net, we have Process.Start which can start an executable. So if we start a PDF file, it will be openend by […]