WPF controls have certain properties (UserControl.Resources, UserControl.CommandBindings) that can have elements added to them from the XAML declaration of a user control. Example:
<UserControl ... > <UserControl.CommandBindings> ... </UserControl.CommandBindings> <UserControl.Resources> ... </UserControl.Resources> </UserControl>
I have a new list property defined in my user control:
public partial class ArchetypeControl : UserControl { ... public List<Object> UICommands { get; set; }
I want to add elements to this list as I can, with resources and CommandBindings, but when I do this:
<c:ArchetypeControl.UICommands> </c:ArchetypeControl.UICommands>
I get the error "Error 4. The attachable property" UICommands "was not found in the type" ArchetypeControl ".
Suggestions?
-
Given the comments, I created a test control to show all the code and reproduce the problem. I am using visual studio 2010.
<UserControl x:Class="ArchetypesUI.TestControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:c="clr-namespace:ArchetypesUI" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300"> <c:TestControl.TestObject> </c:TestControl.TestObject> <Grid> </Grid> </UserControl>
-
namespace ArchetypesUI {
Now I get the error "Error 2 Nested property TestControl.TestObject" is not defined in "UserControl" or in one of its base classes.
Jared source share