I defined a style in ResourceDictionaryfor the button with the image:
<Style x:Key="BotonIrAInicioStyle" TargetType="Button">
<Setter Property="Margin" Value="0"/>
<Setter Property="Width" Value="{Binding RelativeSource={RelativeSource Self}, Path=ActualHeight}"/>
<Setter Property="Content">
<Setter.Value>
<Image Margin="2" Source="{StaticResource IconoDashboardBlanco}" MaxHeight="20" Stretch="Uniform"
RenderOptions.BitmapScalingMode="HighQuality"/>
</Setter.Value>
</Setter>
</Style>
The image source is defined in another ResourceDictionaryin the same assembly and is marked as x:Shared="False":
<BitmapImage x:Key="IconoDashboardBlanco" x:Shared="False"
UriSource="pack://application:,,,/QualityFramework;component/Images/dashboard64X64.png"/>
Since the style will be used in another assembly, I used the notation "pack://application:,,,"to refer to the image. For the Build Actionimage is set to Resource (Do not copy to output directory).
In the main assembly, I have two UserControlsthat display a button with the same style:
<Button DockPanel.Dock="Left" Style="{StaticResource BotonIrAInicioStyle}" Click="BotonIrAInicio_Click"/> (Click event has nothing to do with the problem)
Problem:
UserControl A, , . UserControl B, , ok. UserControl A, . , UserControl B, UserControl A, "" .
, x:Shared="False", URI notation Build Action... , . .
? !
PS: , , - !