I'm trying to create custom control for my WPF application and cant understand why its not working.
I have two projects - one is my custom control library with one custom control derived from Image with only few methods and the second project where I want to use my control. I dont want to do anything with styles or binding, so I'm using defaults.
So, my custom control theme (generic.xaml):
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:RTPlayer">
<Style
TargetType="{x:Type local:RTPlayer}" BasedOn="{StaticResource {x:Type Image}}">
</Style>
And code part:
namespace RTPlayer
{
public class RTPlayer : Image
{
static RTPlayer()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(RTPlayer), new FrameworkPropertyMetadata(typeof(RTPlayer)));
}
public void Start()
{
// ....
}
}
}
In my main project I have added reference to my library .dll file and I'm trying to use control as:
<Window x:Class="rtspWPF.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:rtspWPF"
xmlns:CustomControls="clr-namespace:RTPlayer;assembly=RTPlayer"
xmlns:CustomControls="clr-namespace:RTPlayer;assembly=RTPlayer"
Title="MainWindow" Height="auto" Width="auto">
<CustomControls:RTPlayer x:Name="image" Margin="10,10,10,10" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="auto" Height="auto"/>
The problems is - 1) xaml CustomControl:RTPlayer string warns me: "cant find resource named "System.Windows.Controls.Image". Resource names are case sensitive"; 2) If I'm trying to launch app its throw a Markup.XamlParseException that Markup.StaticResourceHolder throw exception..
What is wrong with my code?
XamlParseException.InnerException?