How to rotate an image ?
Use the TransformedBitmap element to rotate an image. [XAML] <Image Width=’200′ Height=’200′> <Image.Source> <TransformedBitmap Source=’C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Winter.jpg’> <TransformedBitmap.Transform> <RotateTransform Angle=’270′ /> </TransformedBitmap.Transform> </TransformedBitmap> </Image.Source> </Image>
How can I convert an Image to grayscale ?
This can be done by using the ‘FormatConvertedBitmap’ class. The image is converted to the spcified PixedFormat type. The following code snippet shows the conversion of an image to grayscale. [XAML] <Image Width=’200′ Height=’200′ > <Image.Source> <FormatConvertedBitmap Source=’C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Winter.jpg’ DestinationFormat=’Gray4′ /> </Image.Source> </Image>
How can I reflect via data binding the current Zoom value of a DocumentViewer in a TextBlock?
This example shows how to reflect the ‘Zoom’ value of a DocumentViewer in a TextBlock. [XAML] <Window x:Class=’SDKSample.Window1′ xmlns=’http://schemas.microsoft.com/winfx/2006/xaml/presentation’ xmlns:x=’http://schemas.microsoft.com/winfx/2006/xaml’> <Grid> <Grid.RowDefinitions> <RowDefinition Height=’*’ /> <RowDefinition Height=’*’ /> </Grid.RowDefinitions> <DocumentViewer Name=’dvZoomSource’ Grid.Row=’0′ /> <TextBlock Grid.Row=’1′ Text='{Binding ElementName=dvZoomSource, Path=Zoom, Mode=OneWay}’ /> </Grid> </Window>
How can I extend the style of a DocumentViewer ?
The following style uses the ‘BasedOn’ attribute to extend the default DocumentViewer style. [XAML] <Window x:Class=’SDKSample.Window1′ xmlns=’http://schemas.microsoft.com/winfx/2006/xaml/presentation’ xmlns:x=’http://schemas.microsoft.com/winfx/2006/xaml’> <Window.Resources> <Style x:Key=’MyDVStyleExtend’ BasedOn='{StaticResource {x:Type DocumentViewer}}’ TargetType='{x:Type DocumentViewer}’> <Setter Property=’Background’> <Setter.Value> <LinearGradientBrush StartPoint=’0.5,0′ EndPoint=’0.5,1′> <GradientStop Offset=’0.0′ Color=’#CC99CCFF’ /> <GradientStop Offset=’1.0′ Color=’White’ /> </LinearGradientBrush> </Setter.Value> </Setter> </Style> </Window.Resources> <Grid> <DocumentViewer Style='{StaticResource MyDVStyleExtend}’ Name=’MyDocumentViewer’/> </Grid> </Window>
How can I enable a Context Menu on a disabled Control ?
This example uses the ContextMenuService.ShowOnDisabled property to show the context menu for a disabled button. [XAML] <Button Height=’30’ Content=’Disabled Button’ IsEnabled=’False’ ContextMenuService.ShowOnDisabled=’True’> <Button.ContextMenu> <ContextMenu> <MenuItem Header=’Item 1’/> <MenuItem Header=’Item 2’/> <MenuItem Header=’Item 3’/> </ContextMenu> </Button.ContextMenu> </Button>