Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Sample Applications/WPFGallery/Controls/ColorTile.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
Background="Transparent"
BorderBrush="Transparent"
Foreground="{TemplateBinding Foreground}"
Command="ApplicationCommands.Copy"
FocusManager.IsFocusScope="True"
ToolTipService.ToolTip="Copy brush name">
<TextBlock FontFamily="Segoe Fluent Icons" FontSize="16" Text="&#xE8C8;" />
</Button>
Expand Down
24 changes: 23 additions & 1 deletion Sample Applications/WPFGallery/Controls/ColorTile.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ namespace WPFGallery.Controls
/// </summary>
public partial class ColorTile : UserControl
{
static ColorTile()
{
CommandManager.RegisterClassCommandBinding(typeof(ColorTile), new CommandBinding(ApplicationCommands.Copy, Copy_ColorBrushName));
}

public CornerRadius TileRadius
{
get { return (CornerRadius)GetValue(TileRadiusProperty); }
Expand Down Expand Up @@ -81,6 +86,23 @@ public bool ShowWarning
// Using a DependencyProperty as the backing store for ShowSeparator. This enables animation, styling, binding, etc...
public static readonly DependencyProperty ShowWarningProperty =
DependencyProperty.Register("ShowWarning", typeof(bool), typeof(ColorTile), new PropertyMetadata(false));


private static void Copy_ColorBrushName(object sender, RoutedEventArgs e)
{
if(sender is ColorTile colorTile)
{
if(!string.IsNullOrEmpty(colorTile.ColorBrushName))
{
try
{
Clipboard.SetText(colorTile.ColorBrushName);
}
catch (Exception ex)
{
MessageBox.Show("Error copying to clipboard: " + ex.Message);
}
}
}
}
}
}