mirror of
https://github.com/ckaczor/ChrisKaczor.Wpf.Controls.Toolbar.git
synced 2026-01-13 17:22:33 -05:00
Initial commit
This commit is contained in:
25
ImageButton/ImageButton.xaml
Normal file
25
ImageButton/ImageButton.xaml
Normal file
@@ -0,0 +1,25 @@
|
||||
<Button x:Class="ChrisKaczor.Wpf.Controls.Toolbar.ImageButton"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="20"
|
||||
d:DesignWidth="20">
|
||||
<Button.Resources>
|
||||
<Style TargetType="{x:Type Image}"
|
||||
x:Key="toolbarImageStyle">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type Button}, AncestorLevel=1}, Path=IsEnabled}"
|
||||
Value="False">
|
||||
<Setter Property="Opacity"
|
||||
Value="0.25" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Button.Resources>
|
||||
<Image x:Name="image"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource toolbarImageStyle}" />
|
||||
</Button>
|
||||
30
ImageButton/ImageButton.xaml.cs
Normal file
30
ImageButton/ImageButton.xaml.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace ChrisKaczor.Wpf.Controls.Toolbar
|
||||
{
|
||||
public partial class ImageButton
|
||||
{
|
||||
public ImageButton()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
Loaded += HandleImageButtonLoaded;
|
||||
}
|
||||
|
||||
void HandleImageButtonLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (Style == null && Parent is ToolBar)
|
||||
{
|
||||
Style = (Style) FindResource(ToolBar.ButtonStyleKey);
|
||||
}
|
||||
}
|
||||
|
||||
public ImageSource ImageSource
|
||||
{
|
||||
get { return image.Source; }
|
||||
set { image.Source = value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user