Monday, 28 May 2012

WPF Controls Slide out-then-in effect



Please Refer Above Document Outline. here i am using Border as a container ,
Ex:


<telerik:RadTabItem Name="PassPreviewTab"
                                Padding="4 1"
                                DropDownContent="Find Record">
                <telerik:RadTabItem.Content>
                    <Border Name="PassPreviewBorder"
                            BorderBrush="White"
                            BorderThickness="1"
                            Margin="10"
                            VerticalAlignment="Stretch"
                            HorizontalAlignment="Stretch"
                            Background="#FFE0F1F8"
                            CornerRadius="10">
                        <Border.Effect>
                            <DropShadowEffect Direction="150" Opacity="0.21" Color="#FF0C0C0C"/>
                        </Border.Effect>

                        <Border.Child>
                            <Grid>
                               // To Do : Add any controls
                            </Grid>
                        </Border.Child>
                    </Border>
                </telerik:RadTabItem.Content>
            </telerik:RadTabItem>

---------------------------------------------------------------------------------------------------------------
Code :


<UserControl.Resources>

        <Storyboard x:Key="SlideIn" >
            <ThicknessAnimation Duration="0:0:.75" Storyboard.TargetProperty="Margin" From="500,0,-500,0" To="0" DecelerationRatio=".9" />
        </Storyboard>

        <Storyboard x:Key="SlideOut">
            <ThicknessAnimation Duration="0:0:.5" Storyboard.TargetProperty="Margin" To="-500,0,500,0" AccelerationRatio=".9"/>
        </Storyboard>

    </UserControl.Resources>

----------------------------------------------------------------------------------------

Code for Slide In Effect for the Border

Storyboard storyboard = Resources["SlideIn"] as Storyboard;
storyboard.Begin(PassPreviewBorder); 


Thursday, 24 May 2012

Validate Email with Regular Expressions


string ValidEmailExpression = @"^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}$";

Validate numeric Inputs with Regular Expressions


 public static bool IsItNumber(string inputvalue)
        {
            Regex isnumber = new Regex("[^0-9]");
            return !isnumber.IsMatch(inputvalue);
        }


Thursday, 17 May 2012

Rotate Text in WPF


<TextBlock
        Text="Some Text"
        Grid.Row="8"                                                              
        FontSize="9"                                                       
        Height="25"
        Width="auto"                                                                                                                              
        Grid.Column="2"
        VerticalAlignment="Bottom"
        TextAlignment="Center"
        Margin="5,0,-260,-35">
  <TextBlock.RenderTransform>
<TransformGroup>                                       
 <RotateTransform Angle="-90"/>
       </TransformGroup>                                          
 </TextBlock.RenderTransform>
</TextBlock>