Floating FB sharing byReview Results

Floating FB sharing byReview Results

  • WPF Tutorial

    • # Read in Your Language


    WPF Controls

    Tutorial Home | Layouts | Containers | Button | CheckBox and CheckedListBox | ComboBox| DateTimePicker and MonthCalendar | DataGrid | Label and LinkLabel| ListBox | ListView | TextBox and MaskedTextBox| PictureBox and ProgressBar | TreeView | WebBrowser| Menus,Status and Toolbar | RadioButton | RichTextBox| ToolTip and Scrolling | Custom Controls

    Button control in WPF

    Button:


    Namespace : System.Windows.Controls.Button

    Designer Code:

    <!--Window1.XAML-->
    <Button Click="OnButtonClicked">Click me!</Button>

    Code Behind:

    // Window1.xaml.cs
    private void OnButtonClicked(object sender, EventArgs e){
    MessageBox.Show("Clicked!");
    }


    This is a ContentControl.

    For image property add in a stack panel, an image element and a text element.

    Button with Image:
    
            <Button Name="ImageBtn" Width="30" Height="20" Click="OnClickButton">
            <Image Source="Path\Image.jpg"></Image>
            </Button>
            

    
            void OnClickButton(object sender, RoutedEventArgs e)
            {
                ImageBtn.Content = "Image Test";
                ImageBtn.Background = Brushes.Blue;
            }
            

    For cancel buttons, set IsCancel=”true”
    For accept (OK) buttons, set IsDefault=”true”

    Setting Button Template:
          
           <Button x:Name="BtnWithTemplate">            
              <Button.Template>  
                <ControlTemplate> 
                 <Border HorizontalAlignment="Center" VerticalAlignment="Center" >
                 <Image Source="Path\Image.jpg" Width="20" Height="20"/>  
                 </Border>                
                </ControlTemplate>
              </Button.Template>
           </Button>  
            
    Controls inside Button :
          
        <Button x:Name="Samaple"
        HorizontalContentAlignment="Stretch"
        Padding="0"
        Background="Transparent"
        BorderBrush="Transparent" 
        BorderThickness="0"
        Width="200"
        Height="200">
        <Grid >
         <StackPanel>
          <Label Width="200" Height="26" Content="Image test"/>
          <Image Width="190" Height="30" Source="Path\win2wpf.JPG" />
         </StackPanel>                
        </Grid> 
        </Button> 
        





    << Previous >> | << Next >>