Tag Archives: WPF

Visual Studio 2017 Extension development tutorial, Part 4: Show a popup Window

Tutorial Table of Contents:

Part 1: Introduction to VS extensibility
Part 2: Add Menu Item
Part 3: Add command to context menu and get selected code
Part 5: Highlight code in Editor
part 6: Follow a span of code with TrackingSpan

During the tutorial we are going to build a VS extensions called CodyDocs and place it on GitHub. Each tutorial part is a standalone tutorial on a specific topic and can be viewed individually. CodyDocs will save code documentation in a separate file and the extension will allow to view and edit the documentation in the editor itself.

Part 4: Show a popup Window

In the previous part we created a Command that appears in the code editor’s context menu.

Let’s place our logic to run on our command’s callback:

ShowAddDocumentationWindow is the only line relevant to this part of the tutorial.

To show our own custom popup window, Microsoft recommends using DialogWindow, which is what we will do. This is a WPF window which allows you to act as a modal dialog. Which means the popup blocks the rest of Visual Studio UI until closed.

Continue reading

Creating an ecosystem with Continuous Integration, Installer and Deployments for a WPF / UWP application

I’ve been developing Windows desktop applications for many years now, and the operations behind the development process always fascinated me. I mean matters like issues tracking, build machine, installer and deployments. Everything  that involves in a developing a successful project, that’s not directly writing code.

In recent years buzz words like Continuous Integration and Devops popped up into consciousness, which partly describe this process.

I’m going to write here about the tools and technology stacks we have to choose and implement to create a successful ecosystem for your project.

The Goal

In between buzz words, it’s a bit hard to understand what is continuous integration and what exactly we are trying to achieve.

One way of defining it is that continuous integration means to have an automated work flow, in which every time a developer checks in code, it will compile and build on a dedicated server. This dedicated server will also run tests and if the build fails, or if at least one of the tests fail, the check-in will be rejected.

Now let’s go a bit further and think about Deployment. By that, I mean the way you deliver your software to the customer. Let’s assume for now, you want to give him a setup.exe, which he can run on his PC and install the program.

Our dedicated CI server should  also produce such a setup.exe file and even upload this file to some other server dedicated to published versions that the customer can download and install.

Out CI server is also there for the QA department, which needs to get product versions, test them, open bugs and get new versions with fixed bugs.

Part of this process which I described is called Continuous Integration. But, I also want to talk about the Deployment part which is a close cousin of the continuous integration and they both compose the ecosystem of the development process.

Continue reading

WPF complete guide to Themes and Skins

In WPF we define a UI resource system (mostly in XAML resource dictionaries) which includes colors, templates, icons, styles and so on. Sometimes, we need the ability to change our application’s look and feel dynamically, allowing different Themes or Skins.

We might have Shared resources for all Themes and Dynamic resources based on the current Theme or Skin.

The following article talks about the different ways to build a theming/skinning infrastructure in a WPF application.

Continue reading

WPF XAML Resource Benchmark

WPF is very dynamic and allows us to use resources in many different ways. We can use Static or Dynamic. We can place all our resources in App.xaml or use merged dictionaries each time.

You can see all the approaches and what I think is best practice in my WPF Merged Dictionary problems and solutions post.

If you’re new to WPF resources, I suggest reading my Explicit, Implicit and Default styles in WPF post before diving into this one.

This benchmark is supposed to show, in numbers, how any approach affects performance.
Here’s what I want answered with this benchmark:

  1. Is splitting resources in App.xaml to many Merged Dictionaries file vs. one long App.xaml file means longer application startup time?
  2. Is loading all resources in App.xaml once better than loading the resources every time with merged dictionary?
  3. Is DynamicResource instead of StaticResource an issue? How big of an issue?’

Continue reading

4 Tips to increase productivity with WPF Converters

When starting with WPF, I had a hard time realizing when to use converters and just how powerful they can be. I would often create styles with complicated Data Triggers, or abuse my ViewModel instead of doing some simple converter magic.

I’ll share with you some converter tips and tricks that make my development easier every day.

Continue reading

WPF page navigation like in MVC part 2: The MVVMC Framework

Before reading this, check out my last post. I talked about navigation techniques in MVVM and how I didn’t like them too much. I also talked about learning Asp.NET Core is and how good the navigation / routing system is in there.

So, following the pain, I decided to create a lightweight navigation WPF framework similar to the one in Asp.NET Core. We’re still using MVVM, but adding controllers which makes it MVVMC, Model-View-ViewModel-Controller (This is how the library is called as well).

Everything is available on GitHub.
Now let’s see how to use MVVMC with a WPF application:

Continue reading

WPF page Navigation like in MVC – Building an MVVM framework with Controllers

Have you ever considered how WPF does navigation between pages with MVVM?

You’ve got your View and ViewModel, which present a single page, or some area in your page. But what’s the guideline to actually change the content of the page to a new View and ViewModel?

I think MVVM doesn’t really explain that. Which is strange because in almost any application you’d have multiple pages and some sort of flow.
And what about wizard-type applications? What is supposed to happen when I click that “Next” button?

Recently I worked on an ASP.NET Core project and I discovered Microsoft did a very good job implementing navigation with MVC. It’s extremely intuitive and easy to understand.

So after mulling over this for a while, I did the only reasonable thing anyone in my situation would do. I went ahead and built a framework in WPF to implement navigation like in ASP.Net Core.

Continue reading

Reusing UI components in WPF: A case study

In WPF you can do everything in many different ways. It’s not always clear what is better. For example, we got many different ways to reuse a UI component. We can use Templates, User controls, Custom controls, ViewModels with data templates and so on. So which is better? The answer is obvious. Always use user controls!

Just kidding 🙂 The answer is always different, depending on your specific scenario. And a lot of times, it’s far from obvious what’s better. Just for the fun of it, let’s explore one of those scenarios where it’s not so clear which is better.

Continue reading