Thursday, 17 May 2012

Set Control’s Row Definition at run-time


Control ( Stack Panel ) at Design Time 

<StackPanel   HorizontalAlignment="Right"
              Name="spDate"
              Grid.Row="2"
Grid.Column="1"                 
Orientation="Horizontal">
                                                       
            <Label 
Content="Valid Till :"              FontSize="11"                                                          
Name="lblValidTill"
VerticalAlignment="Center" />
                                                   
<Label Content=""
       FontSize="11"
       HorizontalAlignment="Right"
       Name="lblValidTillPP"
VerticalAlignment="Center"/>                                                       
</StackPanel>


Set Control’s Row Definition at run-time

Grid.SetRow(spDate, 2);

Wednesday, 9 May 2012

Button with Rounded Corners in WPF

First Created a Style


<Style x:Key="RoundButtonTemplate" TargetType="Button">
        <Setter Property="Background" Value="Brown"/>
        <Setter Property="Foreground" Value="White" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Border CornerRadius="15" Background="{TemplateBinding Background}"
                                BorderThickness="1">
                        <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center">

                        </ContentPresenter>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

Call the style to Respective Button. 

<Button Focusable="False"
        Style="{StaticResource RoundButtonTemplate}"
        Width="264"
       Height="90" 
       Grid.Row="0"
       Margin="0,0,0,0"
       HorizontalAlignment="Center"
       BorderBrush="#FFF"
       Name="PasswordButton"
       Click="PasswordButton_Click"> 
                                             
</Button>