b

blu

Tuesday, 22 January 2013

CheckBox in Silverlight 5

CheckBox in Silverlight 5


CheckBox in Silverlight 5 C# VB.NET

Step 1) Checkbox has 3 states 1.checked 2.Unchecked 3.indeterminate(default not enabled).

It will be used for multiple selection options.
for ex: programmer has skills C#,VB.NET,JAVA and PHP.

Step 2) In this example added 3 check boxes
YES,NO,N/A check box.

Button controls navigates all these check boxes and displays selected checkboxes values.

        <CheckBox Content="Yes" 
            HorizontalAlignment="Left"
            VerticalAlignment="Top" />
        <CheckBox Content="No"
            HorizontalAlignment="Left"
            VerticalAlignment="Top"
            Margin="0,40,0,0"/>
        <CheckBox Content="N/A"
            HorizontalAlignment="Left"
            VerticalAlignment="Top"
            Margin="0,88,0,0"/>
        <Button Content="Get Checked Buttons"
            x:Name="checked_Button_List"
            HorizontalAlignment="Left"
            VerticalAlignment="Top"
            Width="254" Margin="10,265,0,0"
            Click="checked_Button_List_Click"/>

        <sdk:Label Background="Gray"
                   Name="txtChkStatus"
                   HorizontalAlignment="Left"
                   Height="97" 
                   Foreground="WhiteSmoke"
                   VerticalAlignment="Top"
                   Width="254"  Content=""
                   Margin="10,163,0,0"/>
       
        <sdk:Label Content="Checkbox in Silverlight 5"
                   FontSize="25"
                   Foreground="Gray"
                   Margin="10,330,-10,91"
                   FontFamily="Comic Sans MS"
                   RenderTransformOrigin="0.513,4.359"
                    >
            <sdk:Label.Background>
                <LinearGradientBrush
                    StartPoint="0.30,0.2"
                    EndPoint="0.30,0.99">
                    <GradientStop
                        Color="Yellow" 
                        Offset="0.5">
                    </GradientStop>
                    <GradientStop
                        Color="YellowGreen" 
                        Offset="1.5">
                    </GradientStop>
                </LinearGradientBrush>
            </sdk:Label.Background>
        </sdk:Label>

In the Button Handler, Loops through all controls in the Grid Layout and gets CheckBox List, in that selected one's displayed on the label.

C#

 private void checked_Button_List_Click(
            object sender, RoutedEventArgs e)
        {
            txtChkStatus.Content = String.Empty;

            var chkQuery =
                LayoutRoot.Children.OfType<CheckBox>();

            foreach (CheckBox chk in chkQuery)
            {
            if (chk.IsChecked.HasValue
                && chk.IsChecked.Value==true)

                txtChkStatus.Content +=
                    chk.Content + " " + "Checked\r\n";
             
            }
        }

VB.NET

Private Property checked_Button_List_Click(() As void
 End Property
            Object Function e)() As sender,RoutedEventArgs
            txtChkStatus.Content = String.Empty

            var chkQuery =
                LayoutRoot.Children.OfType<CheckBox>()

            Dim chk As CheckBox
            For Each chk In chkQuery
            If if(chk.IsChecked.HasValue Then
                And chk.IsChecked.Value=True)

                txtChkStatus.Content +=
                    chk.Content + " " + "Checked\r\n"
            End If

            Next
            End Function
Checkbox  Text on Left   change flowdirection "right to left"

Checkbox  Text on Left silverlight 5 C# vb.net

Tags:
CheckBox in Silverlight 5, Check box in Silverlight 5, CheckBox in XAML,Left Text Checkbox in XAML,Silverlight,WPF, Choice/options Checkbox in WPF,Get Selected Checkboxs value.

Sunday, 13 January 2013

Get Silverlight version using VB.NET



Step 1)  Add  Namespace Microsoft.Win32

Step 2)    Get/Read Silverlight Version using C#.


Private Sub Read_registry_keys()
    Dim value As [String] = DirectCast(Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Silverlight", "Version", "10.01"), [String])
    'if no Version entry found  under Silverlight, default value is 10.01
    Console.WriteLine("Silverlight version:{0}", value)
End Sub

'this is for Windows 64-bit versions for 32-bit

Output
Silverlight version:5.1.10411.0


Get Silverlight Version using C#



Step 1)  Add  Namespace Microsoft.Win32

Step 2)    Get/Read Silverlight Version using C#.


void Read_registry_keys()
        {
       String value=(String) Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Silverlight",
"Version", "10.01");   //if no Version entry found  under Silverlight, default value is 10.01
       Console.WriteLine("Silverlight version:{0}",value);
        }


Output
Silverlight version:5.1.10411.0


Thursday, 10 January 2013

TabControl in Silverlight C#/VB.NET

 TabControl in Silverlight C#/VB.NET



TabControl has set of tabs. Its mainly used to view multiple sections/categories  in the same page.
This example has 7 tabs(7wonders). Each tab speaks about one wonders of the world.

Step 1)
            Case 1)  Drag & Drop TabControl
                     xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"  will be added automatically
            Case 2)  Manually adding TabControl , u need to refer Silverlight XAML SDK,shown in Case 1
             Add as many tabs as you require.
for ex:
              <TabControl>
                  <TabItem Header="Taj Mahal"/>
                 <TabItem Header="Colosseum"/>
                </TabControl>
it may not recognize , so add namespace <sdk:TabControl  etc.,

Step 2) Create Styles for each tab header
            <Style x:Key="tabForeKey" TargetType="TabItem">
                <Setter Property="FontWeight" Value="ExtraBold"></Setter>
                <Setter  Property="Foreground">
                    <Setter.Value>
                        <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.89,0.99">
                            <GradientStop Color="teal" Offset="0.23"></GradientStop>
                            <GradientStop Color="Green"  Offset="0.56"></GradientStop>
                        </LinearGradientBrush>
                    </Setter.Value>
                </Setter>
            </Style>

Step 3) Create Styles to Content in Each TabItem

            <Style x:Key="textForeKey" TargetType="TextBlock">
                <Setter  Property="Foreground">
                    <Setter.Value>
                        <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.89,0.99">
                            <GradientStop Color="Gold" Offset="0.23"></GradientStop>
                            <GradientStop Color="Goldenrod"  Offset="0.56"></GradientStop>
                        </LinearGradientBrush>
                    </Setter.Value>
                </Setter>
            </Style>

Step 4) Apply Styles to TabItem Header

            <TabItem Header="Taj Mahal(India)"
                     FontFamily="fonts/tullyshandregular.ttf#TullysHand"
                     Style="{StaticResource tabForeKey}"
                     ScrollViewer.VerticalScrollBarVisibility="Visible"
                       ScrollViewer.HorizontalScrollBarVisibility="Visible"
                     >


Step 5) Apply Styles to Content in TabItem








                    <TextBlock Grid.Column="01" Grid.Row="0"
                        FontFamily="Baris Cerin Regular"  FontSize="16" TextWrapping="Wrap"
                       Style="{StaticResource textForeKey}" >

Step 6)  Run The Application
TabControl Example in Silverlight C#/VB.NET,TabControl Tutorial in Silverlight C#/VB.NET,TabControl in XAML




Complete XAML Code

<navigation:Page
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
           xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
    x:Class="SilverlightApplication.TabControl_demo1"
           mc:Ignorable="d"
           d:DesignWidth="640" d:DesignHeight="480"
           Title="TabControl_demo1 Page">
    <Grid>
        <Grid.Resources>
            <Style x:Key="textForeKey" TargetType="TextBlock">
                <Setter  Property="Foreground">
                    <Setter.Value>
                        <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.89,0.99">
                            <GradientStop Color="Gold" Offset="0.23"></GradientStop>
                            <GradientStop Color="Goldenrod"  Offset="0.56"></GradientStop>
                        </LinearGradientBrush>
                    </Setter.Value>
                </Setter>
            </Style>
            <Style x:Key="tabForeKey" TargetType="sdk:TabItem">
                <Setter Property="FontWeight" Value="ExtraBold"></Setter>
                <Setter  Property="Foreground">
                    <Setter.Value>
                        <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.89,0.99">
                            <GradientStop Color="teal" Offset="0.23"></GradientStop>
                            <GradientStop Color="Green"  Offset="0.56"></GradientStop>
                        </LinearGradientBrush>
                    </Setter.Value>
                </Setter>
            </Style>


        </Grid.Resources>
        <Grid.RowDefinitions>
            <RowDefinition Height="50"></RowDefinition>
            <RowDefinition></RowDefinition>
        </Grid.RowDefinitions>
        <TextBlock Text="TabControl Demo in Silverlight 5"
                   Grid.Column="0" Grid.Row="0"
                   Style="{StaticResource textForeKey}"
                   FontFamily="times"
                   FontSize="20"
                 
                   ></TextBlock>
        <sdk:TabControl  Grid.Column="0" Grid.Row="1" x:Name="SevenWondersTabControl1" HorizontalAlignment="Left"
Height="500" VerticalAlignment="Top" Width="455">
           
                <sdk:TabItem  Header="Taj Mahal(India)"
                     FontFamily="fonts/tullyshandregular.ttf#TullysHand"
                     Style="{StaticResource tabForeKey}"
                     ScrollViewer.VerticalScrollBarVisibility="Visible"
                       ScrollViewer.HorizontalScrollBarVisibility="Visible"
                     >
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition></RowDefinition>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition></ColumnDefinition>
                            <ColumnDefinition  ScrollViewer.VerticalScrollBarVisibility="Visible"
                       ScrollViewer.HorizontalScrollBarVisibility="Auto"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <Image Grid.Column="0" Grid.Row="0"
                           Source="http://tinyurl.com/az89umz" />
                        <ScrollViewer Grid.Column="1" Grid.Row="0">
                            <TextBlock Grid.Column="01" Grid.Row="0"
                        FontFamily="Baris Cerin Regular"  FontSize="16" TextWrapping="Wrap"
                       Style="{StaticResource textForeKey}"
>
                    <Run>
                    The Taj Mahal (/ˈtɑːdʒ məˈhɑːl/ often pron.: /ˈtɑːʒ/;[1] Hindi: ताज महल, from Persian/Urdu:
                        تاج محل‎ "crown of palaces", pronounced
                    </Run>
                    <LineBreak/>
                    <Run>[ˈt̪aːdʒ mɛˈɦɛl]; also "the Taj"[2]) is a white marble mausoleum located in Agra,
                        Uttar Pradesh, India. It was built by Mughal emperor Shah Jahan in </Run>
                    <LineBreak></LineBreak>
                    <Run>
                        memory of his third wife, Mumtaz Mahal. The Taj Mahal is widely recognized as
                        "the jewel of Muslim art in India and one of the universally</Run>
                    <LineBreak></LineBreak>
                    <Run>
                    admired masterpieces of the world's heritage"
                    </Run>
                            </TextBlock>
                        </ScrollViewer>
                    </Grid>
                </sdk:TabItem>
                <sdk:TabItem  Header="Chichen Itza(Mexico)"
                     FontFamily="fonts/tullyshandregular.ttf#TullysHand"
                     Style="{StaticResource tabForeKey}" >
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition></RowDefinition>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition></ColumnDefinition>
                            <ColumnDefinition  ScrollViewer.VerticalScrollBarVisibility="Visible"
                       ScrollViewer.HorizontalScrollBarVisibility="Auto"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <Image Grid.Column="0" Grid.Row="0"
                           Source="http://tinyurl.com/akox5pv" />
                        <ScrollViewer Grid.Column="1" Grid.Row="0">
                            <TextBlock Grid.Column="01" Grid.Row="0"
                        FontFamily="Baris Cerin Regular"  FontSize="16" TextWrapping="Wrap"
                       Style="{StaticResource textForeKey}"
>
                    <Run>
Chichen Itza was a major focal point in the northern Maya lowlands from the Late Classic (c.600–900 AD)
through the Terminal Classic (c.800–900) and into the early portion of the Early Postclassic period (c.900–1200).
The site exhibits a multitude of architectural styles, reminiscent of styles
                    </Run>
                    <LineBreak/>
                    <Run>
seen in central Mexico and of the Puuc and Chenes styles of the northern Maya lowlands.
The presence of central Mexican styles was once thought to have been representative of
direct migration or even conquest from central Mexico, but most contemporary interpretations view the
                    </Run>
                    <LineBreak></LineBreak>
                    <Run>
presence of these non-Maya styles more as the result of cultural diffusion.
                    </Run>
                    <LineBreak></LineBreak>
                            </TextBlock>
                        </ScrollViewer>
                    </Grid>
                </sdk:TabItem>
                <sdk:TabItem  Header="Christ the Redeemer(Brazil)"
                     FontFamily="fonts/tullyshandregular.ttf#TullysHand"
                     Style="{StaticResource tabForeKey}">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition></RowDefinition>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition></ColumnDefinition>
                            <ColumnDefinition  ScrollViewer.VerticalScrollBarVisibility="Visible"
                       ScrollViewer.HorizontalScrollBarVisibility="Auto"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <Image Grid.Column="0" Grid.Row="0"
                           Source="http://tinyurl.com/alrn7ut" />
                        <ScrollViewer Grid.Column="1" Grid.Row="0">
                            <TextBlock Grid.Column="01" Grid.Row="0"
                        FontFamily="Baris Cerin Regular"  FontSize="16" TextWrapping="Wrap"
                       Style="{StaticResource textForeKey}"
>
                    <Run>
The Cristo Redentor (English: lit. Christ the Redeemer, Portuguese: Cristo Redentor, standard) is a statue of
                        Jesus of Nazareth in Rio de Janeiro, Brazil; considered the largest Art Deco statue in
                        the world and the 5th largest statue of Jesus in the world. It is 30.1 metres (99 ft)
                   
                    </Run>
                    <LineBreak/>
                    <Run>
tall, not including its 9.5 metres (31 ft) pedestal, and 30 metres (98 ft) wide. It weighs 635 tonnes
(625 long,700 short tons), and is located at the peak of the 700-metre (2,300 ft)
Corcovado mountain in the Tijuca Forest National Park overlooking the city.
                    </Run>
                    <LineBreak></LineBreak>
                    <Run>
 A symbol of Brazilian Christianity, the statue has become an icon for Rio de Janeiro and Brazil.[1]
                        It is made of reinforced concrete and soapstone, and was constructed between
                        1922 and 1931.[2][3][4]
                    </Run>
                    <LineBreak></LineBreak>
                            </TextBlock>
                        </ScrollViewer>
                    </Grid>
                </sdk:TabItem>
                <sdk:TabItem  Header="Colosseum(Italy)"
                     FontFamily="fonts/tullyshandregular.ttf#TullysHand"
                     Style="{StaticResource tabForeKey}">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition></RowDefinition>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition></ColumnDefinition>
                            <ColumnDefinition  ScrollViewer.VerticalScrollBarVisibility="Visible"
                       ScrollViewer.HorizontalScrollBarVisibility="Auto"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <Image Grid.Column="0" Grid.Row="0"
                           Source="http://tinyurl.com/b899lh8" />
                        <ScrollViewer Grid.Column="1" Grid.Row="0">
                            <TextBlock Grid.Column="01" Grid.Row="0"
                        FontFamily="Baris Cerin Regular"  FontSize="16" TextWrapping="Wrap"
                       Style="{StaticResource textForeKey}"
>
                    <Run>
The Colosseum, or the Coliseum, originally the Flavian Amphitheatre (Latin: Amphitheatrum Flavium, Italian
                        Anfiteatro Flavio or Colosseo), is
                    </Run>
                    <LineBreak/>
                    <Run>
                   
an elliptical amphitheatre in the centre of the city of Rome, Italy, the largest ever built
                        in the Roman Empire, built of concrete and stone.[1] It is                    
                    </Run>
                    <LineBreak></LineBreak>
                    <Run>
considered one of the greatest works of Roman architecture and Roman engineering.
                    </Run>
                    <LineBreak></LineBreak>
                            </TextBlock>
                        </ScrollViewer>
                    </Grid>
                </sdk:TabItem>
                <sdk:TabItem  Header="Great Wall of China(China)"
                     FontFamily="fonts/tullyshandregular.ttf#TullysHand"
                     Style="{StaticResource tabForeKey}">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition></RowDefinition>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition></ColumnDefinition>
                            <ColumnDefinition  ScrollViewer.VerticalScrollBarVisibility="Visible"
                       ScrollViewer.HorizontalScrollBarVisibility="Auto"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <Image Grid.Column="0" Grid.Row="0"
                           Source="http://tinyurl.com/acryvu4" />
                        <ScrollViewer Grid.Column="1" Grid.Row="0">
                            <TextBlock Grid.Column="01" Grid.Row="0"
                        FontFamily="Baris Cerin Regular"  FontSize="16" TextWrapping="Wrap"
                       Style="{StaticResource textForeKey}"
>
                    <Run>
The Great Wall of China is a series of fortifications made of stone, brick, tamped earth,
wood, and other materials, generally built along an east-to-west line across the historical
northern borders of China in part to protect the Chinese Empire or its prototypical
states against intrusions by various nomadic groups or military incursions by various
warlike peoples or forces. Several walls were being built as early as the 7th century
                    </Run>
                    <LineBreak/>
                    <Run>
BC;[3] these, later joined together and made bigger, stronger, and unified are now collectively
referred to as the Great Wall.[4] Especially famous is the wall built between
                    </Run>
                    <LineBreak></LineBreak>
                    <Run>
220–206 BC by the first Emperor of China, Qin Shi Huang. Little of that wall remains. Since then,
                      </Run>
                              <LineBreak></LineBreak>
                    <Run>
                     
the Great Wall has on and off been rebuilt, maintained, and enhanced; the majority of the
existing wall was reconstructed during the Ming Dynasty.
                    </Run>
                            </TextBlock>
                        </ScrollViewer>
                    </Grid>
                </sdk:TabItem>
                <sdk:TabItem  Header="Machu Picchu(Peru)"
                     FontFamily="fonts/tullyshandregular.ttf#TullysHand"
                     Style="{StaticResource tabForeKey}">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition></RowDefinition>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition></ColumnDefinition>
                            <ColumnDefinition  ScrollViewer.VerticalScrollBarVisibility="Visible"
                       ScrollViewer.HorizontalScrollBarVisibility="Auto"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <Image Grid.Column="0" Grid.Row="0"
                           Source="http://tinyurl.com/arcdxab" />
                        <ScrollViewer Grid.Column="1" Grid.Row="0">
                            <TextBlock Grid.Column="01" Grid.Row="0"
                        FontFamily="Baris Cerin Regular"  FontSize="16" TextWrapping="Wrap"
                       Style="{StaticResource textForeKey}"
>
                    <Run>
Machu Picchu (Spanish pronunciation: [ˈmatʃu ˈpiktʃu], Quechua: Machu Picchu [ˈmɑtʃu ˈpixtʃu], "Old Peak")
                        is a pre-Columbian 15th-century Inca
                    </Run>
                    <LineBreak/>
                    <Run>
site located 2,430 metres (7,970 ft) above sea level.[1][2] Machu Picchu is located in the Cusco Region of Peru,
South America. It is situated on a mountain ridge above the Urubamba Valley in Peru, which is 80 kilometres (50 mi)
northwest of Cusco and through which the Urubamba River
 </Run>
                    <LineBreak></LineBreak>
                    <Run>
flows. Most archaeologists believe that Machu Picchu was built as an estate for the
Inca emperor Pachacuti (1438–1472). Often referred to as the "City of the Incas",
it is perhaps the most familiar icon of Inca civilization.
</Run>
                    <LineBreak></LineBreak>
                            </TextBlock>
                        </ScrollViewer>
                    </Grid>
                </sdk:TabItem>
                <sdk:TabItem  Header="Petra(Jordan)"
                     FontFamily="fonts/tullyshandregular.ttf#TullysHand"
                     Style="{StaticResource tabForeKey}">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition></RowDefinition>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition></ColumnDefinition>
                            <ColumnDefinition  ScrollViewer.VerticalScrollBarVisibility="Visible"
                       ScrollViewer.HorizontalScrollBarVisibility="Auto"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <Image Grid.Column="0" Grid.Row="0"
                           Source="http://tinyurl.com/atflxrd" />
                        <ScrollViewer Grid.Column="1" Grid.Row="0">
                            <TextBlock Grid.Column="01" Grid.Row="0"
                        FontFamily="Baris Cerin Regular"  FontSize="16" TextWrapping="Wrap"
                       Style="{StaticResource textForeKey}"
>
                    <Run>
Petra (Greek πέτρα (petra), meaning 'stone'; Arabic: البتراء, Al-Batrāʾ) is an
Arabian historical and archaeological city in the Jordanian governorate of
                   
                    </Run>
                    <LineBreak/>
                    <Run>Ma'an, that is famous for its rock-cut architecture and water conduit system.</Run>
                    <LineBreak></LineBreak>
                            </TextBlock>
                        </ScrollViewer>
                    </Grid>
                </sdk:TabItem>
            </sdk:TabControl>

    </Grid>

</navigation:Page>