Style does not apply to Win7 x32 (.Net 4.0)
We use our own style image buttons. On our development computer (all Win 7 x64 VS 2013) works well. Also on client computers with Win7 x64.Net 4.5.x.
On a test machine running Win 7 x32.NET 4.0, the image buttons have the standard button style, not the new style. On Win 7 x32 with .Net 4.5 it works. So I think the problem is with the .Net version, not the x32 architecture.
Our style for the image buttons
<!-- Default Template -->
<Style TargetType="{x:Type con:PreparedImageButton}" BasedOn="{x:Null}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type con:PreparedImageButton}">
<Border
x:Name="_PART_BORDER"
CornerRadius="0"
BorderThickness="0"
Width="{TemplateBinding Width}"
Height="{TemplateBinding Height}"
Padding="{TemplateBinding Padding}"
Background="{DynamicResource DefaultBackground}">
<Viewbox Stretch="Uniform">
<ContentPresenter x:Name="_PART_SIGN" Content="{x:Null}" />
</Viewbox>
</Border>
<ControlTemplate.Triggers>
<!-- Background Trigger -->
<!-- Disabled Background -->
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="_PART_BORDER" Property="Background"
Value="{DynamicResource DisabledBackground}" />
</Trigger>
<Trigger Property="IsEnabled" Value="True">
<Setter Property="Cursor" Value="Hand" />
</Trigger>
<!-- Pushed Background -->
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="_PART_BORDER" Property="Background"
Value="{DynamicResource PushedBackground}" />
</Trigger>
<!-- Button Type Trigger -->
<!-- Next -->
<Trigger Property="ButtonType" Value="Next">
<Setter TargetName="_PART_SIGN" Property="Content" Value="{DynamicResource NextSignCanvas}" />
</Trigger>
<!-- Back -->
<Trigger Property="ButtonType" Value="Previous">
<Setter TargetName="_PART_SIGN" Property="Content" Value="{DynamicResource BackSignCanvas}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Most of the time we use DataTemplate for our ViewModel
<!-- Default ViewModel Template -->
<DataTemplate DataType="{x:Type vm:PreparedImageButtonViewModel}">
<con:PreparedImageButton ButtonType="{Binding ButtonType}"
IsVikingStyle="{Binding IsVikingStyle}"
Command="{Binding Command}"
IsEnabled="{Binding IsEnabled}"
Visibility="{Binding IsVisible, Converter={StaticResource BooleanVisibilityConverter}}"
IsCancel="{Binding IsCancel}"
IsDefault="{Binding IsDefault}"
ToolTip="{Binding ToolTip}"
Width="{DynamicResource DefaultButtonHeight}"
Padding="{DynamicResource DefaultSignPadding}"
Height="{DynamicResource DefaultButtonHeight}" />
</DataTemplate>
And in the Window / User elements, we bind these buttons to the ContentControl:
<ContentControl Content="{Binding ProtocolButton}" Margin="0,0,5,0" HorizontalAlignment="Right" />
Any idea what will go wrong with .Net 4.0?
Win7 x32.Net 4.0 Win7 x64.Net 4.5
Edit
It looks like .Net 4.0 is not able to correctly resolve merged dictionaries. We usually combine external dictionaries in the Global.xaml of the current project.
If we do this with an image button, it doesn't work. If we merge the image button dictionary right in Windows / UserControl where we use them, this works (under .Net 4.0).
For all other controls, the merge works without issue.
We are testing now if the problem exists if we build the solution on a machine with only .Net 4.0 and VS2010.
source to share
the solution for me was as follows:
remove the whole resource dictionary from app.xaml and add them programmatically:
in the constructor App.xaml.cs
var item = new ResourceDictionary
{
Source = new Uri("link to a skin for example")
};
Current.Resources.MergedDictionaries.Add(item);
_appboot = new Bootstrapper();
var bootRd = new ResourceDictionary {{"bootstrapper", _appboot}};
Current.Resources.MergedDictionaries.Add(bootRd);
this should fix the problem.
information on the issue can be found here: https://msdn.microsoft.com/en-us/library/ee941656(VS.100).aspx#windows_presentation_foundation_wpf
source to share