github twitter email rss
WinForms
0001 Jun 1
One minute read

WinForms, Windows Forms

WPF in WinForms

http://stackoverflow.com/questions/535812/using-a-custom-wpf-control-in-winforms

animation min max

http://www.pinvoke.net/default.aspx/user32.showwindow

WinForms MVVM

ICommand winforms

http://stackoverflow.com/questions/1685088/binding-to-commands-in-winforms
http://www.codeproject.com/Articles/364485/MVVM-Model-View-ViewModel-Patte
http://codewithpassion.blogspot.ru/2010/11/icommand-and-commandmanager-for-windows.html

ListBox tips

Track focused element

BindingList<string> list;
listBox.DataSource = list;
listBox.SelectionMode = SelectionMode.One;
listBox.SelectedValueChanged += delegate
    {
        var value = listBox.SelectedItem;
    };
// When changing binding list SelectedValueChanged will not raise so need to track focused element
list.ListChanged += delegate 
    {
        var value = listBox.SelectedItem;
    };

ComboBox tips

Check for selectin changes

comboBox.SelectedValueChanged += delegate
    {
        var value = uiPlanSelector.SelectedItem;
    };

Populate read only

var list = List<string>();
comboBox.DataSource = list

Populate editable source

// source should implement INotifyPropertyChanged and raise event when change ValuesProperty
comboBox.DataBindings.Add("DataSource", source, "ValuesProperty");

WinForms Checked List Box

Using CheckedListBox

multiple selection is not supported
datasource etc not supported

Using ListView

allows for multiple selection

  • CheckBoxes to true
  • HeaderStyle to None
  • View to Details

Back to posts


comments powered by Disqus