I have a Style for my Images placed in the Window.Resources:
<Style TargetType="{x:Type Image}">
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" Value="0.3" />
</Trigger>
</Style.Triggers>
</Style>
and I have a Toolbar:
<ToolBarTray DockPanel.Dock="Top" Background="Transparent">
<ToolBar Band="0" BandIndex="0" x:Name="ToolbarCATIAAccess" Background="{DynamicResource linearGradBrushHellaTitanMenu}">
<Button Name="ButtonInsertIntoProduct">
<Image x:Name="ImageInsertIntoProduct" Source="/HKBEStandardsFromPDMLibrary;component/Resources/InsertIntoCATIAProduct.png"
ToolTip="insert files into active CATIA Product"/>
</Button>
<Button Name="ButtonCopyFilesToWIN">
<Image x:Name="ImageCopyFilesToWIN" Source="/HKBEStandardsFromPDMLibrary;component/Resources/CopyFilesToWIN.png"
ToolTip="copy files to WIN folder"></Image>
</Button>
</ToolBar>
</ToolBarTray>
This style works for all Images on the whole Window and also in other applications. But it does not work for the first Image in the Toolbar and it does not matter which one comes first, the Opacity is not set at the first. If i add an hidden (Button) Image as First Image into the Toolbar it works for the first visible.
...
<Button Name="ButtonCopyFilesToWIN_" Visibility="Collapsed">
<Image x:Name="ImageCopyFilesToWIN_" Source="/HKBEStandardsFromPDMLibrary;component/Resources/CopyFilesToWIN.png"
ToolTip="copy files to WIN folder"></Image>
</Button>
<Button Name="ButtonInsertIntoProduct">
<Image x:Name="ImageInsertIntoProduct" Source="/HKBEStandardsFromPDMLibrary;component/Resources/InsertIntoCATIAProduct.png"
ToolTip="insert files into active CATIA Product"/>
</Button>
...
Does anyone here has an idea what could be the problem and could help me? Thanks
I've taken your resource and toolbar code snippets and placed in simple app to prove if working or not and in my example it behaves as I would expect. I changed the Opacity to 0 to make it obvious as the image disappears.
The images in the snippet are my sample ones, just revert back to yours. By explicitly setting the IsEnabled property in the images on the snippet below you see if the style is being applied. Here the second image disappears (as IsEnabled is false and set opacity on your style to 0), if you swap the IsEnabled properties on the images so the second image is true and first is false then the first image disappears. So style is being applied to basic example app shown below.
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Dictionary1.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Grid>
<ToolBarTray DockPanel.Dock="Top" Background="Transparent">
<ToolBar Band="0" BandIndex="0" x:Name="ToolbarCATIAAccess" >
<Button Name="ButtonInsertIntoProduct">
<Image x:Name="ImageInsertIntoProduct" Source="scroll1.png" IsEnabled="True"
ToolTip="insert files into active CATIA Product"/>
</Button>
<Button Name="ButtonCopyFilesToWIN">
<Image x:Name="ImageCopyFilesToWIN" Source="scroll2.png" IsEnabled="False"
ToolTip="copy files to WIN folder"></Image>
</Button>
</ToolBar>
</ToolBarTray>
</Grid>
Only other code in example app (Dictionary1.xaml - a resource dictionary file):
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="{x:Type Image}">
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" Value="0" />
</Trigger>
</Style.Triggers>
</Style>