Is there a way to use a Delegate on the TabControl?
Currently, I have (in XAML):
SelectionChanged="radTabControl1_SelectionChanged"
in the ViewModel:
And my otherwise empty .xaml.cs file:
It works, but aren't we supposed to be able to do things without the code-behind?
Or, is there a better way to bind to the SelectedIndex ?
Currently, I have (in XAML):
SelectionChanged="radTabControl1_SelectionChanged"
in the ViewModel:
| public ICommand TabSelectionChangedCommand { get; private set; } |
| TabSelectionChangedCommand = new DelegateCommand<object>(param => |
| { |
| SelectionChanged(param); |
| }); |
| private void SelectionChanged(object obj) |
| { stuff } |
And my otherwise empty .xaml.cs file:
| private void radTabControl1_SelectionChanged(object sender, System.Windows.RoutedEventArgs e) |
| { |
| FrameworkElement fe = (FrameworkElement)sender; |
| MyViewModel mvm = (MyViewModel) ((ObjectDataProvider)fe.DataContext).ObjectInstance; |
| if (mvm != null) |
| { |
| mvm.TabSelectionChangedCommand.Execute(sender); |
| } |
| } |
| |
It works, but aren't we supposed to be able to do things without the code-behind?
Or, is there a better way to bind to the SelectedIndex ?