WPF binding mahapps metro icons in template - wpf

I would like to transform this button code into a template version and put it in a style xaml file:
<Button Background="Transparent" BorderBrush="Transparent" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="20" Foreground="White" Opacity="1">
<StackPanel Orientation="Horizontal">
<Rectangle Width="24" Height="24" Fill="{Binding RelativeSource={RelativeSource AncestorType=Button}, Path=Foreground}">
<Rectangle.OpacityMask>
<VisualBrush Stretch="Fill" Visual="{iconPacks:PackIconMaterial Kind=Face, Width=24, Height=24}" />
</Rectangle.OpacityMask>
</Rectangle>
<TextBlock Margin="10 0 10 0" VerticalAlignment="Center" Text="John Doe" FontSize="24" FontWeight="Normal" FontFamily="Segoe UI Light" />
</StackPanel>
</Button>
I have this until now:
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<StackPanel Name="ButtonGrid" RenderTransformOrigin="0.5,0.5">
<Rectangle Width="48" Height="48" Fill="{Binding RelativeSource={RelativeSource AncestorType=Button}, Path=Foreground}">
<Rectangle.OpacityMask>
<VisualBrush Stretch="Fill" Visual="{Binding Path=(extensions:Icons.IconKind), RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"/>
</Rectangle.OpacityMask>
</Rectangle>
<iconPacks:PackIconSimpleIcons x:Name="btnIcon" Kind="{Binding Path=(**extensions:Icons.IconKind**), RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}" Width="48" Height="48" VerticalAlignment="Top" HorizontalAlignment="Center" Foreground="{TemplateBinding Foreground}" />
<TextBlock x:Name="tButton" HorizontalAlignment="Center" VerticalAlignment="Bottom" Foreground="{TemplateBinding Foreground}" FontWeight="Bold" Text="{Binding Path=Content, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}" />
<StackPanel.RenderTransform>
<ScaleTransform ScaleX="1.0" ScaleY="1.0" CenterX="0.5" CenterY="0.5"/>
</StackPanel.RenderTransform>
</StackPanel>
<ControlTemplate.Triggers>
...
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
In a perfect world, the icon specified in the visual property should be set dynamically in the visual attribute of the template.
I came up with this solution but it doesn't work. Binding can only be done on DependencyProperty.
<VisualBrush Stretch="Fill" Visual="{iconPacks:PackIconMaterial Kind={Binding Path=(extensions:Icons.IconKind)}, Width=48, Height=48}"/>
Any idea how to do it? i'm not this good with template expressions :/

You could define a Template with a VisualBrush that binds to the Tag property of the Button:
<Style x:Key="IconStyle" TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<StackPanel Orientation="Horizontal"
DataContext="{Binding RelativeSource={RelativeSource AncestorType=Button}}">
<Rectangle Width="24" Height="24" Fill="{Binding Foreground}">
<Rectangle.OpacityMask>
<VisualBrush Stretch="Fill" Visual="{Binding Tag}" />
</Rectangle.OpacityMask>
</Rectangle>
<TextBlock Margin="10 0 10 0" VerticalAlignment="Center" Text="John Doe"
FontSize="24" FontWeight="Normal" FontFamily="Segoe UI Light" />
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
...and then set the Tag property to an icon:
<Button Style="{StaticResource IconStyle}" Foreground="Green">
<Button.Tag>
<iconPacks:PackIconMaterial Kind="Face" Width="24" Height="24" />
</Button.Tag>
</Button>

Related

Changing ModalDialog Title bar background color

We have a WPF windows application, We need to change the Modal dialog title bar color, Below is the code snippet and also the screenshot of current dialog box. We are using WPF DevExpress.Xpf third party dlls.
We have tried background color change option also at various places but nothing works and title bar colro wont get changed.
<coreClient:BaseWindow x:Name="ModalDialogWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
ShowInTaskbar="False"
Height="10" Width="10"
Activated="ModalDialogWindowActivated"
Icon="/Images/app_icon_small.png"
Title="{Binding Path=DialogTitle}">
<coreClient:BaseWindow.Resources>
<converter:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
<converter:EmptyStringToVisibilityConverter x:Key="EmptyStringToVisibilityConverter" />
<converter:ModalDialogActionCommandArgsConverter x:Key="ModalDialogActionCommandArgsConverter" />
</coreClient:BaseWindow.Resources>
<DockPanel LastChildFill="True">
<Border Height="35" DockPanel.Dock="Bottom" Margin="0" Style="{StaticResource BdrModalDialogActionPanel}">
<DockPanel LastChildFill="True">
<StackPanel x:Name="actionButtonPanel"
Orientation="Horizontal"
DockPanel.Dock="Right"
HorizontalAlignment="Right"
VerticalAlignment="Center">
<ItemsControl Name="actionButtons"
ItemsSource="{Binding ActionButtons}"
HorizontalAlignment="Right"
Focusable="False"
VerticalAlignment="Center">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button x:Name="additionalActionButton"
IsDefault="{Binding IsButtonDefault}"
IsCancel="{Binding IsButtonCancel}"
IsEnabled="{Binding IsButtonEnabled}"
Content="{Binding Path=Content}"
HorizontalAlignment="Center" VerticalAlignment="Center"
Margin="0,0,5,0"
ToolTipService.ShowOnDisabled="True"
Command="{Binding Path=ActionCommand}" Height="29">
<Button.CommandParameter>
<MultiBinding Converter="{StaticResource ModalDialogActionCommandArgsConverter}">
<MultiBinding.Bindings>
<Binding ElementName="ModalDialogWindow" />
<Binding />
</MultiBinding.Bindings>
</MultiBinding>
</Button.CommandParameter>
<Button.Style>
<Style TargetType="{x:Type Button}">
<Style.Triggers>
<Trigger Property="Content" Value="Search">
<Setter Property="Foreground" Value="White"/>
<Setter Property="Height" Value="29" />
<Setter Property="Width" Value="76" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid Background="#0096d6" x:Name="RootElement">
<TextBlock Text="{TemplateBinding Content}" Foreground="{TemplateBinding Foreground}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
</Button.Style>
<Button.ToolTip>
<ToolTip Visibility="{Binding TooltipText, Converter={StaticResource EmptyStringToVisibilityConverter}, ConverterParameter='HIDDEN'}"
Content="{Binding TooltipText}" />
</Button.ToolTip>
</Button>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
<StackPanel Orientation="Horizontal"
DockPanel.Dock="Left"
Visibility="{Binding IsActionInProgress, Converter={StaticResource BoolToVisibilityConverter}}">
<common:SpinnerControl x:Name="SpinnerControl" VerticalAlignment="Center" VerticalContentAlignment="Center" />
<TextBlock Text="{Binding ActionStatusMessage}"
Margin="5,0,0,0"
VerticalAlignment="Center"/>
</StackPanel>
</DockPanel>
</Border>
<ContentControl x:Name="MainControl"
IsTabStop="False"
Focusable="False" />
</DockPanel>
</coreClient:BaseWindow>

WPF menu item not clickable with WindowStyle=None with WindowChrome [duplicate]

I have a custom WindowChrome style for my WPF app (ripped from here: http://www.bdevuyst.com/wpf-custom-title-bar-and-taskbar/).
Code here:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity">
<!-- Simple style without anything to remove the title bar -->
<Style x:Key="Style.Window.WindowStyleNoneWithTaskbar.Base" TargetType="{x:Type Window}">
<Setter Property="shell:WindowChrome.WindowChrome" >
<Setter.Value>
<shell:WindowChrome GlassFrameThickness="0" />
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Window}">
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding Foreground}" BorderThickness="1" >
<ContentPresenter Content="{TemplateBinding Content}" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- Simple style with system buttons upper right -->
<Style TargetType="{x:Type Window}" BasedOn="{StaticResource Style.Window.WindowStyleNoneWithTaskbar.Base}" x:Key="Style.Window.WindowStyleNoneWithTaskbar">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Window}">
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding Foreground}" BorderThickness="1">
<Grid>
<ContentPresenter
Content="{TemplateBinding Content}" />
<Canvas Grid.Column="2" HorizontalAlignment="Right" Margin="0,6,10,0" VerticalAlignment="Top" >
<Button x:Name="MinimizeButton" Style="{DynamicResource Style.Button.Core.Transparent}" Command="{Binding Source={x:Static SystemCommands.MinimizeWindowCommand}}" Width="24" Height="24" Canvas.Right="55" WindowChrome.IsHitTestVisibleInChrome="True" ToolTip="Close" >
<Rectangle Margin="2" Fill="{DynamicResource appbar.reduce}" Opacity=".5" Width="15" Height="15" />
</Button>
<Button x:Name="NormalizeButton" Style="{DynamicResource Style.Button.Core.Transparent}" Visibility="Collapsed" Command="{Binding Source={x:Static SystemCommands.RestoreWindowCommand}}" Width="24" Height="24" Canvas.Right="30" WindowChrome.IsHitTestVisibleInChrome="True" ToolTip="Restore" >
<Rectangle Margin="2" Fill="{DynamicResource appbar.normal}" Opacity=".5" Width="15" Height="15" />
</Button>
<Button x:Name="MaximizeButton" Style="{DynamicResource Style.Button.Core.Transparent}" Command="{Binding Source={x:Static SystemCommands.MaximizeWindowCommand}}" Width="24" Height="24" Canvas.Right="30" WindowChrome.IsHitTestVisibleInChrome="True" ToolTip="Maximize" >
<Rectangle Margin="2" Fill="{DynamicResource appbar.maximize}" Opacity=".5" Width="15" Height="15" />
</Button>
<Button x:Name="CloseButton" Style="{DynamicResource Style.Button.Core.Transparent}" Command="{Binding Source={x:Static SystemCommands.CloseWindowCommand}}" Width="24" Height="24" Canvas.Right="5" WindowChrome.IsHitTestVisibleInChrome="True" ToolTip="Close" >
<Rectangle Margin="2" Fill="{DynamicResource appbar.close}" Opacity=".5" Width="15" Height="15" />
</Button>
</Canvas>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="WindowState" Value="Maximized">
<Setter Property="Visibility" Value="Collapsed" TargetName="MaximizeButton" />
<Setter Property="Visibility" Value="Visible" TargetName="NormalizeButton" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
I removed references to "shell:" because it's deprecated, but for some reason I am unable to click the buttons in the title bar. I downloaded the sample solution from the website I linked, and the buttons worked from me.
So next, I added the references to "shell" back, but I was still unable to click the buttons.
I'm not sure what I'm doing wrong here. I pretty much completely copied the sample solution into my project and it still didn't work. I have IsHitTestVisibleInChrome set to "true" for each button but it's not making a difference.
I've tried several other, much more simple approaches, with basic buttons and no styling, all to no avail. I feel like I'm missing something obvious here.
Small addition to the correct answer. If you have something like:
<Button shell:WindowChrome.IsHitTestVisibleInChrome="True"
And your buttons do not react to clicks - just REMOVE "shell:"
<Button WindowChrome.IsHitTestVisibleInChrome="True"
This will make them work
It is your command bindings that are the issue here. Don't bind the Command properties. Simply set them:
<Canvas Grid.Column="2" HorizontalAlignment="Right" Margin="0,6,10,0" VerticalAlignment="Top" >
<Button x:Name="MinimizeButton" Style="{DynamicResource Style.Button.Core.Transparent}" Command="{x:Static SystemCommands.MinimizeWindowCommand}" Width="24" Height="24" Canvas.Right="55" WindowChrome.IsHitTestVisibleInChrome="True" ToolTip="Close" >
<Rectangle Margin="2" Fill="{DynamicResource appbar.reduce}" Opacity=".5" Width="15" Height="15" />
</Button>
<Button x:Name="NormalizeButton" Style="{DynamicResource Style.Button.Core.Transparent}" Visibility="Collapsed" Command="{x:Static SystemCommands.RestoreWindowCommand}" Width="24" Height="24" Canvas.Right="30" WindowChrome.IsHitTestVisibleInChrome="True" ToolTip="Restore" >
<Rectangle Margin="2" Fill="{DynamicResource appbar.normal}" Opacity=".5" Width="15" Height="15" />
</Button>
<Button x:Name="MaximizeButton" Style="{DynamicResource Style.Button.Core.Transparent}" Command="{x:Static SystemCommands.MaximizeWindowCommand}" Width="24" Height="24" Canvas.Right="30" WindowChrome.IsHitTestVisibleInChrome="True" ToolTip="Maximize" >
<Rectangle Margin="2" Fill="{DynamicResource appbar.maximize}" Opacity=".5" Width="15" Height="15" />
</Button>
<Button x:Name="CloseButton" Style="{DynamicResource Style.Button.Core.Transparent}" Command="{x:Static SystemCommands.CloseWindowCommand}" Width="24" Height="24" Canvas.Right="5" WindowChrome.IsHitTestVisibleInChrome="True" ToolTip="Close" >
<Rectangle Margin="2" Fill="{DynamicResource appbar.close}" Opacity=".5" Width="15" Height="15" />
</Button>
</Canvas>
You will also need a command binding for each of the commands and execute them programmatically as suggested by #Louis Kottmann here:
In WPF, can I have a borderless window that has regular minimize, maximise and close buttons?

Bind the error data of datagridrow to a tooltip textblock

I am trying to show the validation error message of data grid row in a tooltip. Here is the code that works when I use the ToolTip property of the Grid control directly (wihtout styling):
<Grid Margin="0,-2,0,-2" ToolTip="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGridRow}}, Path=(Validation.Errors)[0].ErrorContent}">
<Ellipse StrokeThickness="0" Fill="Red"
Width="{TemplateBinding FontSize}"
Height="{TemplateBinding FontSize}" />
<TextBlock Text="!" FontSize="{TemplateBinding FontSize}"
FontWeight="Bold" Foreground="White"
HorizontalAlignment="Center" />
</Grid>
Now this shows the tooltip correctly. Everything is fine.
Problem:
As soon as I start styling the ToolTip separately, the binding stops working somehow. Here is the code that I am trying which does not work:
<Grid Margin="0,-2,0,-2">
<Ellipse x:Name="ErrorEllipse" StrokeThickness="0" Fill="Red"
Width="{TemplateBinding FontSize}"
Height="{TemplateBinding FontSize}" />
<TextBlock Text="!" FontSize="{TemplateBinding FontSize}"
FontWeight="Bold" Foreground="White"
HorizontalAlignment="Center"/>
<Grid.ToolTip>
<ToolTip Background="Transparent" BorderBrush="Transparent" Height="Auto" Width="Auto">
<Border >
<TextBlock Text= "{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGridRow}}, Path=(Validation.Errors)[0].ErrorContent}"
MinHeight="20"
MinWidth="100"
Foreground="White"
Background="Red"/>
</Border>
</ToolTip>
</Grid.ToolTip>
</Grid>
What am I missing here and how can I achieve the proper binding? Probably its something basic but I have no idea...
You should style the ToolTip separately with a ControlTemplate.
<Style x:Key="ValidationToolTipStyle" TargetType="{x:Type ToolTip}">
<Setter Property="Background" Value="Transparent" />
...
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToolTip}">
<Border >
<TextBlock
Text="{TemplateBinding Content}"
MinHeight="20"
MinWidth="100"
Foreground="White"
Background="Red"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Then in your XAML, use the ToolTip like this:
<Grid Margin="0,-2,0,-2">
<Ellipse x:Name="ErrorEllipse"
StrokeThickness="0" Fill="Red"
Width="{TemplateBinding FontSize}"
Height="{TemplateBinding FontSize}" />
<TextBlock
Text="!"
FontSize="{TemplateBinding FontSize}"
FontWeight="Bold"
Foreground="White"
HorizontalAlignment="Center" />
<ToolTipService.ToolTip>
<ToolTip
Style="{StaticResource ValidationToolTipStyle}"
Content="{Binding RelativeSource={RelativeSource AncestorType={x:Type DataGridRow}, Path=(Validation.Errors)[0].ErrorContent}" />
</ToolTip>
</ToolTipService.ToolTip>
</Grid>
I hope this helps.

WPF Templated button - no click event

I'm trying to design a button that has a dashed border all around and an image in the middle. The ideal hit test would be on the image itself, but not a requirement. My problem is that I can't get the click event to fire. It's probably a hit test problem, but I can't figure it out.
In addition to the obvious onClick on the button, I tried MouseEvents on the image, ButtonBase.Click on the Stackpanel, Border.InputBindings on the border .. I thought setting Background=Transparent would do it, but no go.
Here's the xaml:
<Button Grid.Row="0" Click="Button_Click_1">
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<Border Background="Transparent" Grid.Row="0" Margin="30,50" CornerRadius="10" BorderThickness="4">
<Border.BorderBrush>
<VisualBrush>
<VisualBrush.Visual>
<Rectangle StrokeDashArray="4 2"
Stroke="#CEAC2D"
StrokeThickness="4"
RadiusX="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=CornerRadius.TopRight}"
RadiusY="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=CornerRadius.BottomLeft}"
Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualWidth}"
Height="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualHeight}"/>
</VisualBrush.Visual>
</VisualBrush>
</Border.BorderBrush>
<StackPanel Orientation="Vertical" VerticalAlignment="Center" ButtonBase.Click="Button_Click_1">
<Button Height="30" Width="30" Content="Start"/> // just a test button to see if it works
<Image Source="/Images/uploadIcon.png" Height="180"/>
<TextBlock Margin="0,20,0,0" Foreground="#CEAC2D" Text="Drag Folder or Click to Browse" FontFamily="Lato" FontSize="27"
FontWeight="SemiBold" HorizontalAlignment="Center"/>
</StackPanel>
</Border>
</ControlTemplate>
</Button.Template>
</Button>
Why are you trying to set the whole thing as the button's template? If you only want the image bit actually clickable then set that as a button's control template and place it inside a regular visual tree:
<Border Background="Transparent" Grid.Row="0" Margin="30,50" CornerRadius="10" BorderThickness="4">
<Border.BorderBrush>
<VisualBrush>
<VisualBrush.Visual>
<Rectangle StrokeDashArray="4 2"
Stroke="#CEAC2D"
StrokeThickness="4"
RadiusX="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=CornerRadius.TopRight}"
RadiusY="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=CornerRadius.BottomLeft}"
Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualWidth}"
Height="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualHeight}"/>
</VisualBrush.Visual>
</VisualBrush>
</Border.BorderBrush>
<StackPanel Orientation="Vertical" VerticalAlignment="Center">
<Button Click="Button_Click_1" Cursor="Hand">
<Button.Template>
<ControlTemplate TargetType="Button">
<Image Source="/Images/uploadIcon.png" Height="180"/>
</ControlTemplate>
</Button.Template>
</Button>
<TextBlock Margin="0,20,0,0" Foreground="#CEAC2D" Text="Drag Folder or Click to Browse" FontFamily="Lato" FontSize="27"
FontWeight="SemiBold" HorizontalAlignment="Center"/>
</StackPanel>
</Border>

Need to be able to make a canvas defined inside a control template invisible when clicking anywhere other than on the object

I have a user control inside which there is a control template containing a canvas:
<ControlTemplate x:Key="ListBoxItemTemplate"
TargetType="ListBoxItem">
<Grid Width="30"
Height="30">
<!-- IsHitTestVisible=False so you can select enemies when
the infotip is visible and overlaps other enemies
-->
<Canvas x:Name="Inspect"
Visibility="Collapsed"
IsHitTestVisible="False">
<Image Source="/Images/InspectBubble.png"
Width="250" />
<StackPanel Margin="20"
Width="200"
Orientation="Vertical">
<TextBlock Foreground="White"
FontWeight="Bold"
FontSize="9pt"
Margin="2"
Text="{Binding Path=PatientName}"
HorizontalAlignment="Left"
VerticalAlignment="Top"/>
<TextBlock Foreground="White"
FontWeight="Bold"
FontSize="9pt"
Margin="2"
Text="{Binding Path=Icu.IcuName}"
HorizontalAlignment="Left"
VerticalAlignment="Top"/>
<TextBlock Foreground="White"
FontWeight="Bold"
FontSize="9pt"
Margin="2"
Text="{Binding Path=Icu.IcuLocation}"
HorizontalAlignment="Left"
VerticalAlignment="Top"/>
<TextBlock Foreground="White"
FontWeight="Bold"
FontSize="9pt"
Margin="2"
Text="{Binding Path=AgeDisplay}"
HorizontalAlignment="Left"
VerticalAlignment="Top"/>
<TextBlock Foreground="White"
FontWeight="Bold"
FontSize="9pt"
Margin="2"
Text="{Binding Path=LOSDisplay}"
HorizontalAlignment="Left"
VerticalAlignment="Top"/>
</StackPanel>
<Canvas.RenderTransform>
<TranslateTransform X="-150"
Y="-150" />
</Canvas.RenderTransform>
</Canvas>
<ContentPresenter RenderTransformOrigin="0.5,0.5">
<ContentPresenter.RenderTransform>
<RotateTransform Angle="{Binding Angle}" />
</ContentPresenter.RenderTransform>
</ContentPresenter>
<Grid.RenderTransform>
<TranslateTransform X="{Binding Location.X}"
Y="{Binding Location.Y}" />
</Grid.RenderTransform>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected"
Value="True">
<Setter Property="Visibility"
Value="Visible"
TargetName="Inspect" />
<Setter Property="Panel.ZIndex"
Value="1" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
As you can see the Canvas displays the object details when an object is selected - as defined in the Trigger. When I click anywhere outside the object, I want the canvas to become invisible. How can I do this?

Resources