Bind ListBox ItemsSource to DayNames property of DateTimeFormatInfo


   
   

<StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:g="clr-namespace:System.Globalization;assembly=mscorlib">

    <ListBox Name="lstbox"
             HorizontalAlignment="Center"
             Margin="24"
             ItemsSource="{Binding 
                            Source={x:Static g:DateTimeFormatInfo.CurrentInfo},
                            Path=DayNames,
                            Mode=OneTime}" />
</StackPanel>

   
    
    
     


Long Binding Path


   
   

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:s="clr-namespace:System;assembly=mscorlib"
      FontSize="12pt"
      Name="page">
    <StackPanel>
        <TextBlock HorizontalAlignment="Center">
            First element in StackPanel
        </TextBlock>

        <ListBox HorizontalAlignment="Center"
                 Margin="24">
            <ListBoxItem>First</ListBoxItem>
            <ListBoxItem>Second</ListBoxItem>
            <ListBoxItem>Third</ListBoxItem>
            <ListBoxItem>Fourth</ListBoxItem>
            <ListBoxItem>Fifth</ListBoxItem>
        </ListBox>

        <TextBlock HorizontalAlignment="Center">
            <Label Content="Number of characters in third ListBox item = " />
            <Label Content="{Binding ElementName=page, Path=Content.Children&#91;1&#93;.Items&#91;2&#93;.Content.Length}" />
            <LineBreak />
            <Label Content="Number of characters in selected item = " />
            <Label Content="{Binding ElementName=page,Path=Content.Children&#91;1&#93;.SelectedItem.Content.Length}" />
        </TextBlock>
    </StackPanel>
</Page>

   
    
    
     


Binding With Data Context


   
   
<StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <ScrollBar Name="scroll"
               Orientation="Horizontal" Margin="24" 
               Maximum="100" LargeChange="10" SmallChange="1" />

    <Label HorizontalAlignment="Center"
           DataContext="{Binding ElementName=scroll}"
           Content="{Binding Path=Value}" />

</StackPanel>

   
    
    
     


Bind ScrollBar To Label


   
   

<StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <ScrollBar Orientation="Horizontal" Margin="24" 
               Maximum="100" LargeChange="10" SmallChange="1"
               Value="{Binding ElementName=lbl, Path=Content}" />

    <Label Name="lbl" Content="50"
           HorizontalAlignment="Center" />

</StackPanel>

   
    
    
     


Bind Label To ScrollBar


   
   
<StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <ScrollBar Name="scroll"
               Orientation="Horizontal" Margin="24" 
               Maximum="100" LargeChange="10" SmallChange="1" />

    <Label HorizontalAlignment="Center" 
           Content="{Binding ElementName=scroll, Path=Value}" />

</StackPanel>

   
    
    
     


Desktop to Control


   
   

<Window  
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="SDKSample.SampleViewer"
    Title="Examples" >

   <Canvas> 
        <Button Width="120" Height="20">
          <Button.Background>
            <LinearGradientBrush>
              <LinearGradientBrush.GradientStops>
                  <GradientStop Offset="0" Color="{x:Static SystemColors.DesktopColor}"/>
                  <GradientStop Offset="1" Color="{x:Static SystemColors.ControlColor}"/>
              </LinearGradientBrush.GradientStops>
            </LinearGradientBrush>
          </Button.Background>
        </Button> 

   </Canvas> 


</Window>