Trying to design a custom control, but my project won't run. When I try and build, it says "Provide value on 'System.Windows.Markup.StaticResourceHolder' threw an exception. Line number '6' and line position '7'." That line and position is where I define the "TargetType" in my control.
Generic.xaml (where it "breaks")
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:CustomControl">
<Style TargetType="{x:Type local:MySprite}" BasedOn = "{StaticResource {x:Type Image}}">
<Setter Property="Source" Value="MySourceSprite.png"/>
</Style>
</ResourceDictionary>
MySprite.cs
namespace CustomControl
{
public class MySprite : Image
{
static MySprite()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(MySprite), new FrameworkPropertyMetadata(typeof(MySprite)));
}
}
}
MainWindow.xaml
<Window x:Class="CustomControl.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:CustomControl"
xmlns:control="clr-namespace:CustomControl"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid>
<control:MySprite/>
</Grid>
</Window>
What "value" am I not providing?