Wednesday, 30 January 2013

Play video using MediaElement Tag


Replace the below given code with <grid></grid> tag given in your Application

1. Page or Window Tag is depend upon the type of Application you are using


 <Page.Background>
        <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
            <GradientStop Color="Black" Offset="0" />
            <GradientStop Color="#AFFFFFB1" Offset="0.099" />
        </LinearGradientBrush>
    </Page.Background>




<DockPanel>
        <Border Background="{Binding ElementName=color,Path=SelectedItem.Content}" BorderThickness="5" CornerRadius="8" Height="468" Width="466">
            <StackPanel Height="410" Width="448">
                <StackPanel.Effect>
                    <DropShadowEffect Color="CadetBlue" BlurRadius="3" ShadowDepth="15" ></DropShadowEffect>
                </StackPanel.Effect>
                <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="18" Background="Black" Foreground="orange" Height="29" Width="246">here is the demo of video clip</TextBlock>
             
             
                <!--<Expander FontSize="18" Header="expand me to show the video of jab tk h jaan ">-->
                <ComboBox Name="sl" SelectedIndex="0">
                    <ComboBoxItem>D:\ashy\WpfApplication1\songsVideo\jbtkhjaan.mp4</ComboBoxItem>
  <ComboBoxItem>D:\ashy\WpfApplication1\songsVideo\LaptopErgonomics.mp4</ComboBoxItem>
                </ComboBox>
                <MediaElement Volume="80" Opacity="80"  Source="{Binding ElementName=sl,Path=SelectedItem.Content}"></MediaElement>
             
 
            </StackPanel>
        </Border>
        <DockPanel.Background>
            <RadialGradientBrush>
                <GradientStop Color="#FF293955" Offset="0" />
                <GradientStop Color="WhiteSmoke" Offset="0.574" />
            </RadialGradientBrush>
        </DockPanel.Background>
    </DockPanel>



NOTE:
________________________________________________________________
  •  <Border>  tag is optional ,it is  just used to apply border on Page .
  •  <StackPanel.Effect> tag is optional , it is just used to apply some Effects on stack Panel
  •  The Source property specifies name of the media file to be played and it  tag takes the full path of the video file.
  • Let us see how to bind  source attribute with the ComboBox's Element.
          Source="{Binding ElementName=sl,Path=SelectedItem.Content}
           where s1 is the name of ComboBox
  • The RadialGradientBrush is similar in programming model to the LinearGradientBrush. However, the linear gradient has a start and an end point to define the gradient vector, while the radial gradient has a circle, along with a focal point, to define the gradient behavior. The circle defines the end point of the gradient. In other words, a gradient stop at 1.0 defines the color at the circle's circumference. The focal point defines the center of the gradient. A gradient stop at 0.0 defines the color at the focal point.





   





Friday, 25 January 2013

Static Resource Binding

1.Create a resource using markup (XAML)  under  " Page or Window "  tag  .
(depending upon the type of application.....).
e.g.

 Under  Page Tag.

    <Page.Resources>
             <SolidColorBrush x:Key="bgcolor" Color="green"/>
             <SolidColorBrush x:Key="fgcolor" Color="yellow"/>
   </Page.Resources

Under  Window Tag.

    <Window.Resources>
             <SolidColorBrush x:Key="bgcolor" Color="green"/>
             <SolidColorBrush x:Key="fgcolor" Color="yellow"/>
   </Window.Resources>


2. Let us now bind the above created resource with Button. like this:

   <Button Background="{StaticResource bgcolor}"  Foreground="{StaticResource fgcolor}" Height="32">                      
         A button with Resource attached to it.        
   </Button>

3. Now Run Your Application ...........F5.

NOTE :
bgcolor: Background Color.
fgcolor : Foreground  Color







Thursday, 24 January 2013

Procedural Code Inside XAML...


Lets see an example in which procedural code (C#)  is embedded with XAML markup.
Replace the below mentioned code in your xaml markup code..

<grid>
     <Button Click="button_Click" Height="39">
        <x:Code>
            <![CDATA[
                    void button_Click(Object Sender,RoutedEventArgs e)
                   {
                          MessageBox.Show("hello i m clicked!!!");
                   }
            ]]>
       </x:Code>
   </Button>
<grid>