Reputation: 2347
i am written the following xaml code:
<Window x:Class="ImageScrollDemo.View.TestWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="TestWindow" Height="300" Width="300">
<Window.Resources>
<Style x:Key="NextImageButtonStyle" TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Image Source="..\Images\#next.png" RenderOptions.BitmapScalingMode="HighQuality" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
<Grid>
<Button Style="{DynamicResource NextImageButtonStyle}" />
</Grid>
</Window>
The window is rendered blank. i don't understand why.
Upvotes: 0
Views: 680
Reputation: 2618
One thing to note: Try specifying TargetType using Type syntax
<Style x:Key="NextImageButtonStyle" TargetType="{x:Type Button}">
Reference: MSDN Style.TargetType Property
Using the key to refer to the resource may be enough, but an incorrect TargetType could interfere.
Upvotes: 1
Reputation: 7961
<Image Source="..\Images\#next.png" ... />
Check the file name for the image and verify it does actually contain a #
character.
Also, try using a static resource:
<Button Style="{StaticResource NextImageButtonStyle}" />
Upvotes: 1