Implementing InplacePopup in MDriven Applications
The InplacePopup feature in MDriven enables developers to create a dynamic user interface by displaying UI elements only when needed. This tutorial guides you through setting up an InplacePopup in both MDriven Turnkey and WPF applications.
Prerequisites
Before implementing the InplacePopup, ensure you have:
- MDriven Designer installed.
- Basic understanding of ViewModel UX Patterns (Seeker, Dashboard, Forms).
- Familiarity with Layout and CSS for styling.
Step 1: Define the Domain Model
Begin by defining a simple domain model in MDriven Designer. We'll use a class named Sled with attributes like RegistrationNumber and a collection of Box objects.
- Open MDriven Designer and create a new class named
Sled. - Add an attribute
RegistrationNumberof type String. - Create a class
Boxand establish a one-to-many association withSled.
Step 2: Create a ViewModel
Create a ViewModel to represent the UI layout where the InplacePopup will be used.
- Define a ViewModel rooted in
Sled. - Add a nesting for the
Boxcollection. - Set the nesting to use a
PlacingContainerfor rendering.
Step 3: Implement InplacePopup
The InplacePopup allows you to hide UI elements until a user action triggers them.
- Add a button to the ViewModel that will trigger the InplacePopup.
- Use the
Actionproperty to define the behavior when the button is clicked.
- Use the
- Define the InplacePopup by setting the nesting to render as an action.
- Set the
Presentationproperty of the nesting toAction.
- Set the
Step 4: Style the InplacePopup
Styling ensures the InplacePopup integrates seamlessly with your application's UI.
- Create a new style in the model targeting the
PlacingContainer. - Set properties such as background color and border to enhance visibility.
- Apply the style to the InplacePopup using the
StyleExpressionproperty.
self.VMStyles->select(s | s.Name = 'NewStyle1')->first
Step 5: Test the InplacePopup
Run your application to test the InplacePopup functionality.
- Ensure that the popup appears only when the designated button is clicked.
- Verify that the popup content is rendered correctly and that the styling is applied.
The InplacePopup feature in MDriven provides a flexible way to manage UI space by displaying elements only when necessary. By following this tutorial, you can enhance your application's user experience with dynamic content presentation.
For further exploration, consider reviewing Creating CustomControl that Shows Data in a Gantt Chart and PlacingContainer for additional customization options.
Source
Based on the MDriven video WednesdayWithMDriven: InplacePopup.
