I've been writing a WPF program at work that uses a custom AnimatedScrollViewer
control, inheriting from ScrollViewer
. It has the following default template:
<Style TargetType="{x:Type Controls:AnimatedScrollViewer}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:AnimatedScrollViewer}">
<Grid x:Name="PART_LayoutRoot">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ScrollContentPresenter x:Name="PART_ScrollContentPresenter" />
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ScrollBar x:Name="PART_HorizontalScrollBar"
Orientation="Horizontal"
IsEnabled="{TemplateBinding IsPaused}"
Value="{TemplateBinding HorizontalOffset}"
Maximum="{TemplateBinding ScrollableWidth}"
ViewportSize="{TemplateBinding ViewportWidth}"
Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" />
<StackPanel Grid.Column="1">
<Image Source="{StaticResource LockedImage}"
Visibility="{TemplateBinding IsPlaying, Converter={StaticResource boolToVisConverter}}"/>
<Image Source="{StaticResource UnlockedImage}"
Visibility="{TemplateBinding IsPaused, Converter={StaticResource boolToVisConverter}}"/>
</StackPanel>
</Grid>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
I'm setting this as the default style using:
[...]
public class AnimatedScrollViewer : ScrollViewer
{
static AnimatedScrollViewer()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(AnimatedScrollViewer), new FrameworkPropertyMetadata(typeof(AnimatedScrollViewer)));
}
[...]
The style is being referenced in the below Generic.xaml
dictionary, which in turn is referenced as a MergedDictionary
in App.xaml
:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="ConvertersDictionary.xaml" />
<ResourceDictionary Source="pack://application:,,,/JamesWright.Utils.EndpointCaller.Views;component/Themes/EndpointStyles.xaml" />
<ResourceDictionary Source="pack://application:,,,/JamesWright.Utils.EndpointCaller.Views;component/Themes/ImageResources.xaml" />
<ResourceDictionary Source="pack://application:,,,/JamesWright.Utils.EndpointCaller.Views;component/Themes/Resources.xaml" />
<ResourceDictionary Source="pack://application:,,,/JamesWright.Utils.EndpointCaller.Views;component/Controls/AnimatedScrollViewer.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
What's really strange is that the style is only applied to the control when the program runs on my own machine and a Windows 8.1 virtual machine, while it isn't applied on my colleague's computer and a team machine. I know that the style isn't applied because the associated ScrollBar
should only be enabled when 'IsPaused' is true. On my colleague's machine, however, it's always enabled. Also, the images that I've specified in the template don't appear as a result.
Are there any known reasons why a Style
may not be applied on certain machines? I've decompiled the app and the resources are referencing the correct files. Any help is appreciated, as we've been pulling our hair out all day :P
UPDATE: I've downloaded it to my Windows 8 laptop and the style is applied correctly.
UPDATE #2: I attempted to use relative paths as opposed to pack
syntax with no success