lisa-marie mueller

lisa-marie mueller

bullet pont

input validation for WPF user interfaces link

August 7, 2020

typewriter, Cuckoo Clock, marbles in blue User interfaces allow you to customize your plug-ins and provide a better experience. Your UI can be quite simple or more complex to allow users to control a variety of inputs. I’ve posted a few times about the use of Windows Presentation Form (WPF), which is one common way to create user interfaces. There are a lot of options that allow you to customize the interface. You can check out Microsoft’s documentation if you are looking for a place to get started.

goals and considerations

  • create the grids by entering width and height information
  • randomly delete curtain wall grids but allow for user configurations
  • randomize curtain wall panel materials
  • option to remove mullions

WPF form to allow for wall selection

Today, I am going to discuss data validation, specifically for user selected elements. If you are allowing a user to select a Revit element in the project, it is important to confirm the element is of the correct type. This way your application will not throw an error. We can confirm the element type by first assigning our user selected element to a variable or putting multiple elements in a list. For our Curtain Wall Randomizer, the user only selects one element so we can assign it to the variable userObjectSelection. Then we can use the GetElement method to select it and cast it to a Wall because we are expecting a Wall. Since we are specifically looking for a curtain wall, we also need to check that the wall has a CurtainGrid which is a defining factor of a curtain wall. If this check returns null, we know the user did not select a wall and they need to try again. If they did select a wall, then we can move forward and run the rest of our application.


The steps to verify this information will take place in your main method. Similarly, you can check for other element types or iterate over a list to review multiple elements. Next week we will look at one more UI feature, sliders.


If you want to learn to code and don’t know where to start check out my posts about Steps to Learn to Code [for architects and designers] Part 1 and Part 2.

Revit API Docs

bullet pont

recommended next