Need to replace third-party WinForm controls, what is the equivalent of WPF in the closet?

I'm tired of Windows Forms ... I'm simple. I am not trying to start a discussion. I just get bored of this. Unfortunately, we became dependent on 4 controls in DevExpress XtraEditors. I had nothing but difficulties with them, and I want to move on.

Now I need a cabinet replacement for the 4 controls that I use. Here they are:

LookUpEdit is a combobox that filters a drop-down list as you type.

MemoExEdit is a textbox that pops up to a large area when it has focus.

CheckedComboBoxEdit is a checkboxes dropdown menu.

CheckedListBoxControl is a well-chosen listbox of checkboxes

This is a LOB app that has tons of data entry. In fact, the first two are good, but not significant. Secondly, it is important that I need to either reproduce the functionality or change the way users interact with this specific data.

I am looking for help with replication in a WPF environment with existing controls (codeplex, etc.) or in direct XAML . Any code or direction would be greatly appreciated, but basically I hope to avoid any commercial third-party WPFs and instead would like to focus on creating them (but I need direction) or using Codeplex

+4
source share
1 answer

One of the most beautiful things in WPF is how easy it is to customize controls (especially when compared to WinForms). Based on the descriptions you provided, all of these controls can be created quite simply using standard toolbar controls; I do not think that you will need to purchase third-party solutions. Starting at the top:

  • LookUpEdit - You can get it for free using the WPF combo box
  • MemoExEdit - Using the standard TextBox control and the Popup primitive, you can duplicate this effect with relatively little effort.
  • CheckedComboBoxEdit - WPF ComboBox is an ItemsControl , and that means it supports custom item templates. You can do this easily with a couple of XAML lines.
  • CheckedListBoxControl is the same for ListBox using the ItemTemplate property, which you can do this as soon as possible.

Here is a brief example of how you can implement a control similar to CheckedComboBoxEdit . First, the code:

 public partial class CustomControls : Window { public ObservableCollection<CustomItem> Items { get; set; } public CustomControls() { Items = new ObservableCollection<CustomItem>(); Items.Add(new CustomItem() { Name = "Item 1", Checked = true }); Items.Add(new CustomItem() { Name = "Item 2", Checked = false }); Items.Add(new CustomItem() { Name = "Item 3", Checked = false }); InitializeComponent(); } } public class CustomItem { public bool Checked { get; set; } public string Name { get; set; } } 

Now XAML for Window :

 <Window x:Class="TestWpfApplication.CustomControls" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="CustomControls" Height="200" Width="200" DataContext="{Binding RelativeSource={RelativeSource Self}}"> <ComboBox ItemsSource="{Binding Items}" VerticalAlignment="Center" HorizontalAlignment="Center" Width="100"> <ComboBox.ItemTemplate> <DataTemplate> <CheckBox Content="{Binding Name}" IsChecked="{Binding Checked}"/> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox> 

What the ItemTemplate property ItemTemplate : "for each item in this control, make me one of them." Therefore, for each item in the Items the ComboBox collection, a CheckBox is created, and its Content bound to the Name property of your item class and its IsChecked property associated with Checked .

And here is the end result:

alt text http://img155.imageshack.us/img155/9379/customcontrols.png

+9
source

Source: https://habr.com/ru/post/1308176/


All Articles