InputPanel, a popular WinForms control that acts like a complete data-entry form, is now available in WPF and UWP. InputPanel manages the design, layout, appearance, and behavior of multiple input components. Here's a two-minute video that walks you through how to get started in WPF.
Get started with InputPanel for WPF
- First, create a WPF app.
- Drag and drop the InputPanel Control on the form.
- Name it "salesPanel"
- Next, we’ll databind the control with a collection of Sales data.
- Let’s create a Sales class that also returns a list of sales objects.
- Create a ListCollectionView and set its source to the Sales list.
- Next, set the ItemsSource of the InputPanel to this ListCollectionView.
- Run the app.
You’ll see a form displaying sales objects.
We can navigate the records using the next, last, previous, and first buttons.
- The panel displays different editors depending on the data type of the fields. For example, numeric types are displayed using numericInput, text fields are displayed in simple textboxes, checkboxes are used for Booleans, and dateEditors are used to display dates.
A record can be added or deleted using Add\Delete button available in navigation panel.
It’s also possible to display only one record in the input panel.
- First, set the current item of the inputpanel to the ListCollectionView's current item.
- When we run the app, we see that the control displays the current record of the ListCollectionView, which happens to be its first record.
- InputPanel supports data validation out of the box. We’ll use DataAnnotation attributes on the Model properties, and the inputpanel automatically honours that.
- In this example, import the DataAnnotations namespace.
- Add the Required attribute to product field.
- Run the app.
- Delete the value from Product field and click OK. Notice that the panel prompts that Product is required, and it does not update the record.
- InputPanel also supports custom validations and integration with other data-aware controls like FlexGrid and DataGrid.