|
<Window x:Class="DragCanvasDemo.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:jas="clr-namespace:WPF.JoshSmith.Controls"
Title="DragCanvas Demo" Height="700" Width="700"
WindowState="Maximized"
FontSize="14"
>
<Window.Resources>
<ResourceDictionary Source="resources.xaml" />
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<ToolBar>
<ToggleButton Name="btnAllowDragging" IsChecked="True" Content="Allow Dragging" Margin="2,0" />
<Separator />
<ToggleButton Name="btnAllowDragOutOfView" Content="Allow Drag Out Of View" Margin="2,0" />
<Separator />
<ToggleButton Name="btnOnlyShowOffsetIndicators" Content="Only Show Offset Indicators" Margin="2,0" />
</ToolBar>
<jas:DragCanvas x:Name="dragCanvas"
Grid.Row="1"
AllowDragging="{Binding ElementName=btnAllowDragging, Path=IsChecked}"
AllowDragOutOfView="{Binding ElementName=btnAllowDragOutOfView, Path=IsChecked}"
>
<jas:DragCanvas.ContextMenu>
<ContextMenu Opened="OnContextMenuOpened" MenuItem.Click="OnMenuItemClick">
<MenuItem Header="Bring To Front" Name="menuItemBringToFront" />
<MenuItem Header="Send To Back" Name="menuItemSendToBack" />
<Separator />
<MenuItem Header="Can Be Dragged" Name="menuItemCanBeDragged" />
</ContextMenu>
</jas:DragCanvas.ContextMenu>
<Ellipse
Canvas.Left="100" Canvas.Bottom="30"
Width="65" Height="70">
<Ellipse.Fill>
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
<LinearGradientBrush.GradientStops>
<GradientStop Color="LightGray" Offset="0" />
<GradientStop Color="Black" Offset="0.75" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Ellipse.Fill>
</Ellipse>
<Polygon
Canvas.Right="200" Canvas.Top="250"
Width="100" Height="100" Fill="Blue">
<Polygon.Points>
<Point X="0" Y="0" />
<Point X="0" Y="100" />
<Point X="100" Y="50" />
</Polygon.Points>
</Polygon>
<StackPanel
jas:DragCanvas.CanBeDragged="False"
Background="Wheat"
Canvas.Left="40"
Canvas.Bottom="70"
Name="stackPanel"
Orientation="Horizontal">
<TextBlock Text="CanBeDragged = " />
<TextBlock Text="{Binding ElementName=stackPanel, Path=(jas:DragCanvas.CanBeDragged)}" />
</StackPanel>
<Button Click="OnButtonClick" Canvas.Right="120" Canvas.Bottom="10">Josh was here</Button>
<ComboBox Width="200" Canvas.Left="300" Canvas.Top="10" SelectedIndex="0">
<ComboBoxItem>Don't worry, be happy.</ComboBoxItem>
<ComboBoxItem>Hello, World!</ComboBoxItem>
</ComboBox>
<UniformGrid Background="White" Rows="2" Columns="2" Canvas.Left="20" Canvas.Top="200" Width="250" Height="250">
<Border BorderBrush="Black" BorderThickness="1" Background="AliceBlue">
<Image Source="/Images/girls.gif" Width="50" Height="50" />
</Border>
<Border BorderBrush="Black" BorderThickness="1" Background="SeaGreen">
<Image Source="/Images/girls.gif" Width="50" Height="50" />
</Border>
<Border BorderBrush="Black" BorderThickness="1" Background="LightGoldenrodYellow">
<Image Source="/Images/girls.gif" Width="50" Height="50" />
</Border>
<Border BorderBrush="Black" BorderThickness="1" Background="PaleGoldenrod" >
<DockPanel>
<TextBlock
DockPanel.Dock="Top"
FontSize="15"
HorizontalAlignment="Center"
TextAlignment="Center"
>
<Hyperlink>Hello!</Hyperlink>
</TextBlock>
<Image Source="/Images/girls.gif" Width="50" Height="50" />
</DockPanel>
</Border>
</UniformGrid>
<ScrollBar
Canvas.Bottom="90"
Canvas.Right="60"
ContextMenu="{x:Null}"
Width="17" Height="200" />
</jas:DragCanvas>
</Grid>
</Window>
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.