WELCOME TO SILVERLIGHT

DARE TO BE DIFFERENT

Wednesday, June 10, 2009

Using MediaElement Control in Silverlight

  • MediaElement Control enables the user to professionally present the application in Silverlight.
  • MediaElement is same as the image brush,in MediaElement we can add Video and Audio in our applications.

Let us see a simple example

Here we use three Button Control namely Play,Pause andStop.

Play: Plays the Video.

Pause:Pauses the Video.

Stop: Stops the Video.

XAML Coding:

<MediaElement Name="abc" Source="mov1.wmv" ></MediaElement>
<Button Name="a1" Height="40" Width="40" VerticalAlignment="Bottom" HorizontalAlignment="Left" Content="play" Click="Button_Click"></Button>
<Button Name="a2" Height="40" Width="40" VerticalAlignment="Bottom" HorizontalAlignment="Center" Content="pause" Click="Button_Click_1"></Button>
<Button Name="a3" Height="40" Width="40" VerticalAlignment="Bottom" HorizontalAlignment="Right" Content="stop" Click="Button_Click_2"></Button>


C# Coding:

public partial class Page : UserControl
{
public Page()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
abc.Play();
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
abc.Pause();
}
private void Button_Click_2(object sender, RoutedEventArgs e)
{
abc.Stop();
}
}

Output:




Monday, June 8, 2009

Setting Image as Background of a Calendar


<basics:Calendar.Background>
<ImageBrush ImageSource="Garden.jpg" Opacity="0.3"/>
</basics:Calendar.Background>

Formatting a Calendar


<basics:Calendar.BorderBrush>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,1" >
<GradientStop Color="Blue" Offset="0" />
<GradientStop Color="Red" Offset="1.0" />
</basics:Calendar.BorderBrush>

Highlighting a Day in Calendar


MonthlyCalendar.FirstDayOfWeek = DayOfWeek.Monday;
MonthlyCalendar.IsTodayHighlighted = true;

To BlackoutDates in Calendar


private void SetBlackOutDates()
{
MonthlyCalendar.BlackoutDates.Add(new CalendarDateRange(
new DateTime(2009, 1, 1),
new DateTime(2009, 1, 4)
));
}

Selection Modes and Selection Dates in calendar



<basics:Calendar SelectionMode="SingleRange">
<basics:Calendar SelectionMode="SingleDate">
<basics:Calendar SelectionMode="MultipleRange">

Display Modes in Calendar


<basics:calendar displaymode="“Year”">
<basics:calendar displaymode="“Decade”">
<basics:calendar displaymode="“Month”">