Intersoft ClientUI 8 > ClientUI Fundamentals > MVVM Pattern Overview > MVVM Pattern How-to Topics > How-to: Handle UXDockButton Command using MVVM Pattern |
This example shows how to handle UXDockButton command using MVVM pattern.
UXDockButton is inherited from UXStackButton. Therefore it has the same item container type which is UXStackItem.
UXStackItem implements both ICommandSource and INavigationSource that allows both commanding and navigation using UXStackItem. To learn more about commanding, see Commanding Overview.
The following example shows how to handle UXDockButton command using MVVM pattern.
XAML |
Copy Code
|
---|---|
<Intersoft:UXPage.DataContext> <ViewModels:UXPage1ViewModel /> </Intersoft:UXPage.DataContext> <Intersoft:UXDock Intersoft:DockPanel.Dock="Bottom"> <Intersoft:UXDockButton Command="{Binding ClickDockButton}" CommandParameter="Contact" Content="Contact" DisplayMode="Content" VerticalContentAlignment="Bottom" HorizontalContentAlignment="Center" /> <Intersoft:UXDockButton Command="{Binding ClickDockButton}" CommandParameter="Product" Content="Product" DisplayMode="Content" VerticalContentAlignment="Bottom" HorizontalContentAlignment="Center" /> </Intersoft:UXDock> |
C# |
Copy Code
|
---|---|
public class UXPage1ViewModel : ViewModelBase { private DelegateCommand _clickDockButton; public DelegateCommand ClickDockButton { get { return this._clickDockButton; } } public UXPage1ViewModel() { this._clickDockButton = new DelegateCommand(ClickedButton); } private void ClickedButton(object parameter) { if (parameter.ToString() == "Contact"){ MessageBoxServiceProvider.Show("Contact Clicked", null); } else if (parameter.ToString() == "Product") { MessageBoxServiceProvider.Show("Product Clicked", null); } } } |