# Here is an Sample Application in which canvas's backgroundColor is binded with ComboBox. when you select a color from comboBox, canvas changes its backColor accordingly,and textBox shows name of the color.
<Page x:Class="WpfApplication1.databinding"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="databinding">
<StackPanel Height="221" Width="423">
<StackPanel.Background>
<LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
<GradientStop Color="#FFEBEBEB" Offset="0.94" />
<GradientStop Color="#31FFFFFF" Offset="0" />
<GradientStop Color="Black" Offset="1" />
<GradientStop Color="#FFBBBBBB" Offset="0.892" />
</LinearGradientBrush>
</StackPanel.Background>
<TextBlock FontFamily="AvantGarde Bk BT" FontSize="15"><TextBlock.BitmapEffect><DropShadowBitmapEffect /></TextBlock.BitmapEffect>Color in combobox</TextBlock>
<ComboBox FontFamily="AvantGarde Bk BT" x:Name="color" Height="25" Width="152" SelectedIndex="0">
<ComboBox.BitmapEffect>
<DropShadowBitmapEffect />
</ComboBox.BitmapEffect>
<ComboBoxItem>Green</ComboBoxItem>
<ComboBoxItem>LightBlue</ComboBoxItem>
<ComboBoxItem>Red</ComboBoxItem>
</ComboBox>
<Canvas Background="{Binding ElementName=color,Path=SelectedItem.Content}" Height="60" Width="252">
<!-- <Canvas.LayoutTransform>
<RotateTransform Angle="-20" CenterX="10" CenterY="0" ></RotateTransform>
</Canvas.LayoutTransform>-->
<Canvas.BitmapEffect>
<DropShadowBitmapEffect />
</Canvas.BitmapEffect>
</Canvas>
<TextBlock Foreground="{Binding ElementName=color,Path=SelectItem.Content}" VerticalAlignment="Center" HorizontalAlignment="Center" x:Name="hi" Text="{Binding ElementName=color,Path=SelectedItem.Content}" FontSize="13"><TextBlock.BitmapEffect><DropShadowBitmapEffect /></TextBlock.BitmapEffect> </TextBlock>
</StackPanel>
</Page>
No comments:
Post a Comment