Intersoft ClientUI 8 > ClientUI Controls > Control Library > Button Controls Overview > GlassButton |
GlassButton is a lightweight button control featuring many capabilities and behaviors expected in a button control plus a predefined glass style that can be easily customized through available brushes.
GlassButton is inherited from ISButton class which includes fundamental features such as Commanding, Navigation, Toggle, ClickMode and more. To learn more about commanding, see Commanding Overview. To learn more about navigation, see Navigation Overview.
XAML |
Copy Code
|
---|---|
<Intersoft:GlassButton Content="Try Now" VerticalAlignment="Top" HorizontalAlignment="Left" Padding="8,4" Click="GlassButton_Click"></Intersoft:GlassButton> |
C# |
Copy Code
|
---|---|
private void GlassButton_Click(object sender, RoutedEventArgs e) { MessageBox.Show("Glass Button Clicked"); } |
To configure GlassButton as toggle button you need to set the IsToggleButton property to True and specify the GroupName that group the buttons together.
The following example shows how to configure GlassButton as toggle button.
XAML |
Copy Code
|
---|---|
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Horizontal"> <Intersoft:GlassButton Content="ON" Width="50" GroupName="ToggleGroup" IsToggleButton="True" IsChecked="True"/> <Intersoft:GlassButton Content="OFF" Width="50" GroupName="ToggleGroup" IsToggleButton="True"/> </StackPanel> |
You can also use GlassButton to perform navigation to the specified NavigateUri and TargetFrame. This behavior is inherited from ISButton that implements INavigationSource interface.
The following example shows how to perform navigation using GlassButton.
XAML |
Copy Code
|
---|---|
<Intersoft:GlassButton Content="Try Now" NavigateUri="http://www.clientui.com/try" TargetName="_blank" ToolTipService.ToolTip="Visit Download Page"/> |
To learn more about navigation, see Navigation Overview.
Similar to other button controls in ClientUI, GlassButton supports commands that you can bind using MVVM pattern.
The following example shows how to bind a command to GlassButton.
C# |
Copy Code
|
---|---|
using System.ComponentModel; using System.Windows; using Intersoft.Client.Framework.Input; namespace ClientUI.Samples.ViewModels { public class MainPageViewModel : INotifyPropertyChanged { public DelegateCommand SubmitCommand { get; set; } public MainPageViewModel() { this.SubmitCommand = new DelegateCommand(ExecuteSubmit, CanExecuteSubmit); } private bool CanExecuteSubmit(object parameter) { return true; // you can use validation here to determine when the command is available. } private void ExecuteSubmit(object parameter) { MessageBox.Show("Submit"); } protected void OnPropertyChanged(string propertyName) { PropertyChangedEventHandler handler = PropertyChanged; if (handler != null) { handler(this, new PropertyChangedEventArgs(propertyName)); } } public event PropertyChangedEventHandler PropertyChanged; } } |
XAML |
Copy Code
|
---|---|
<Grid x:Name="LayoutRoot" Background="White"> <Grid.DataContext> <vm:MainPageViewModel/> </Grid.DataContext> <Intersoft:GlassButton Content="Submit" HorizontalAlignment="Center" VerticalAlignment="Center" Command="{Binding SubmitCommand}"> </Intersoft:GlassButton> </Grid> |
To learn more about commanding, see Commanding Overview.
You can customize the GlassButton appearance easily from the following properties.
If you need to do more complex customization or if you want to change the styles of each visual states available in GlassButton, you can edit the template and do the modification accordingly.
To learn more how to change the template and the visual states, see Styles and Template Overview.