Stop TabControl from recreating its children

By default, the TabControl shares a panel to render it’s content. To do what you want (and many other WPF developers), you need to extend TabControl like so: TabControlEx.cs [TemplatePart(Name = “PART_ItemsHolder”, Type = typeof(Panel))] public class TabControlEx : TabControl { private Panel ItemsHolderPanel = null; public TabControlEx() : base() { // This is necessary … Read more

Select multiple items from a DataGrid in an MVVM WPF project

You can simply add a custom dependency property to do this: public class CustomDataGrid : DataGrid { public CustomDataGrid () { this.SelectionChanged += CustomDataGrid_SelectionChanged; } void CustomDataGrid_SelectionChanged (object sender, SelectionChangedEventArgs e) { this.SelectedItemsList = this.SelectedItems; } #region SelectedItemsList public IList SelectedItemsList { get { return (IList)GetValue (SelectedItemsListProperty); } set { SetValue (SelectedItemsListProperty, value); } } … Read more

Opening new window in MVVM WPF

You say “creating window instance and showing window from view model is violation of MVVM”. This is correct. You are now trying to create an interface that takes a type of view specified by the VM. This is just as much of a violation. You may have abstracted away the creation logic behind an interface, … Read more