So I have this custom control library consisting of two controls. For some reason, I keep getting errors like "cannot bind properties of ContentPresenter because there is no property named 'Content' on type..." and "the member 'template' is not recognized or is not accessible." All my code seems in line and even after searching google (a hundred times over), I have not been able to figure out what's preventing my solution to build.
Wasted an hour trying to figure this out and I still got nothing. Here's the code:
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:Imagin.Controls">
<Style TargetType="{x:Type local:WorkSpace}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:WorkSpace}">
<ContentPresenter ContentSource="Content" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type local:Tile}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:Tile}">
<ContentPresenter ContentSource="Content" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
Tile.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Imagin.Controls
{
public class Tile : Border
{
public string Title { get; set; }
public bool IsClosable { get; set; }
public bool IsLockable { get; set; }
public Tiles TileType { get; set; }
public Orientations Orientation { get; set; }
static Tile()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(Tile), new FrameworkPropertyMetadata(typeof(Tile)));
}
}
}
WorkSpace.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Imagin.Controls
{
public enum Orientations
{
Top,
TopMiddle,
Middle,
BottomMiddle,
Bottom,
Left,
LeftMiddle,
RightMiddle,
Right
}
public enum Tiles
{
Window,
Tabbed,
Column
}
public class WorkSpace : Grid
{
static WorkSpace()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(WorkSpace), new FrameworkPropertyMetadata(typeof(WorkSpace)));
}
}
}
Any suggestions?