LearnRevitAPI

Nov 7, 2024

🤷‍♂️ What is WPF?

Welcome to WPF Course for pyRevit Users!

In the first module, I'll introduce you to the basic concepts like:
- WPF (Windows Presentation Foundation)
- MVVM (Model-View-ViewModel)
- XAML (eXtensible Application Markup Language)
- How to Setup WPF Dev Environment
- And we will create a simple form together

And in the first lesson we will focus on the most basic question: 🤔 What is WPF and MVVM?

👉 ​Watch Full Lesson here ​

What is WPF?

WPF stands for Windows Presentation Foundation. It's a modern UI framework developed by Microsoft for building good-looking UI Forms or Applications.

It offers a modern approach to designing user interfaces by using XAML file format (eXtensible Application Markup Language). It's made for .NET Framework and can be used with .NET languages like C# or IronPython in our case, for writing the logic.

You will need to connect 2 things together:

  • UI Form (Front-End)

  • Code with Logic (Back-End)

And therefore you will work with 2 files:

  • XAML code

  • Python Code

XAML and Python Files

Let's recap a very important point.
You will need 2 scripts to create custom forms:

  • 1️⃣ XAML Scripts (Front-End)
    Think of XAML as the HTML but for desktop applications.
    It describes the UI Elements and their layout on the form using similar syntax and logic, but it has different names for its components.

  • 2️⃣IronPython Scripts (Back-End):
    You will still write all the UI and Revit API logic and interactions with python inside your scripts as usual. But you will also need to connect it to your XAML form.

💡 There is also a way to make WPF forms only inside of Python code by using Behind-Code concept. But we will leave it for another day.

Why Use WPF?

WPF is very flexible.

You can do anything you can imagine with WPF forms as long as you have the skills. And luckily for you it got so much simpler since Chat GPT release.

Turns out, Chat GPT know XAML really well and it can save you hundreds of hours of creating your forms.

What is MVVM?

Next, let's talk about MVVM, which stands for Model-View-ViewModel

MVVM a design pattern that separates your application into three components:

  1. Model: Manages the data and logic.

  2. View: The UI layer that displays UI Form.

  3. ViewModel: Translator between Model and View to handle data presentation and user commands.

In general it helps you separate the Front-End of your form and Back-End of your code, so it's more maintainable and easier to create.

Still Confused?

By now you might still be confused…
What the hell is MVVM and WPF?

Don't worry, it will all start make a lot more sense when we will start coding with XAML.

The best way of learning to code is by doing. And that's what we will focus on a lot during this course.

But let's take it one step at the time.

P.S.

The Full WPF Course for pyRevit will be released in ~2 weeks.

Meanwhile, I will continue releasing the first module on YouTube. Stay tuned if you want to learn more!



Enjoyed Newsletter?

Leave a Testimonial Here.

⌨️ Happy Coding!
Erik Frits

Join Newsletter

📩 You will be added to Revit API Newsletter

Join Us!

which is already read by 7400+ people!