title: Can't create dependency property in a UserControl in a Windows Runtime Component library
body: <p>I wanted to created data bindable property inside a user control. And this user control contains inside a <strong>"Windows Runtime Component"</strong> project. I used below code to create property.</p>
  
  <pre><code>public MyItem CurrentItem
  {
      get { return (MyItem)GetValue(CurrentItemProperty); }
      set { SetValue(CurrentItemProperty, value); }
  }
  
  // Using a DependencyProperty as the backing store for CurrentItem. 
  // This enables animation, styling, binding, etc...
  public static readonly DependencyProperty CurrentItemProperty =
      DependencyProperty.Register("CurrentItem", typeof(MyItem), typeof(CollapseUserControl), new PropertyMetadata(null));
  </code></pre>
  
  <p>When I compile the project I get below error.</p>
  
  <pre><code>Type 'HierachyLib.CollapseUserControl' contains externally visible field 'HierachyLib.CollapseUserControl.CurrentItemProperty'.  Fields can be exposed only by structures.
  </code></pre>
  
  <p><strong>Update 1 - Source code for whole class</strong></p>
  
  <pre><code>public sealed partial class CollapseUserControl : UserControl, IHierarchyHeightFix
  {
      public MyItem CurrentItem
      {
          get { return (MyItem)GetValue(CurrentItemProperty); }
          set { SetValue(CurrentItemProperty, value); }
      }
  
      // Using a DependencyProperty as the backing store for CurrentItem.  This enables animation, styling, binding, etc...
      public static readonly DependencyProperty CurrentItemProperty =
          DependencyProperty.Register("CurrentItem", typeof(MyItem), typeof(CollapseUserControl), new PropertyMetadata(null));
  
      Boolean viewState = true;
  
      public CollapseUserControl()
      {
          this.DataContext = CurrentItem;
          this.InitializeComponent();
          this.Loaded += CollapseUserControl_Loaded;
      }
  
      void CollapseUserControl_Loaded(object sender, RoutedEventArgs e)
      {
          LoadData();
          if (this.Height.Equals(double.NaN))
          {
              this.Height = 50;
          }
          //this.Height = 50;
          //this.Width = double.NaN;
      }
  
      private void LoadData()
      {
          if (CurrentItem != null)
          {
              if (CurrentItem.IsValueControl)
              {
                  ChildItemContainer.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                  ValueItem.Visibility = Windows.UI.Xaml.Visibility.Visible;
  
                  ValueItem.Text = CurrentItem.Value;
              }
              else
              {
                  ChildItemContainer.Visibility = Windows.UI.Xaml.Visibility.Visible;
                  ValueItem.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
  
                  ChildItems.ItemsSource = CurrentItem.Childs;
                  //foreach (MyItem item in CurrentItem.Childs)
                  //{
                  //    CollapseUserControl control = new CollapseUserControl();
                  //    control.CurrentItem = item;
                  //    ChildItems.Items.Add(control);
                  //}
                  ChildItems.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
              }
          }
  
      }
  
      private void Button_Click_1(object sender, RoutedEventArgs e)
      {
          if (viewState)
          {
              ChildItems.Visibility = Windows.UI.Xaml.Visibility.Visible;
              //show.Begin();
          }
          else
          {
              //hide.Begin();
              ChildItems.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
          }
          viewState = !viewState;
      }
  
      private void hide_Completed_1(object sender, object e)
      {
          ChildItems.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
      }
  
      private void show_Completed_1(object sender, object e)
      {
      }
  }
  </code></pre>
  
  <p><strong>Update 2 : XAML Code</strong></p>
  
  <pre><code>&lt;UserControl
  x:Class="HierachyLib.CollapseUserControl"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:local="using:HierachyLib"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  mc:Ignorable="d"
  d:DesignHeight="300"
  d:DesignWidth="400"&gt;
  &lt;UserControl.Resources&gt;
  
      &lt;DataTemplate x:Key="ReviewsItemsTemplate"&gt;
          &lt;StackPanel Margin="0,0,0,20"&gt;
              &lt;TextBlock Text="TEST" /&gt;
              &lt;TextBlock Text="TEST"/&gt;
          &lt;/StackPanel&gt;
      &lt;/DataTemplate&gt;
      &lt;ItemsPanelTemplate x:Key="ReviewsItemsPanelTemplate"&gt;
          &lt;StackPanel Margin="0,0,0,0" Width="Auto"/&gt;
      &lt;/ItemsPanelTemplate&gt;
  &lt;/UserControl.Resources&gt;
  &lt;!--xmlns:my="clr-namespace:HierarchyCollapse"--&gt;
  &lt;Grid&gt;
      &lt;Grid Name="ChildItemContainer"&gt;
          &lt;Grid.RowDefinitions&gt;
              &lt;RowDefinition Height="40" /&gt;
              &lt;RowDefinition Height="*" /&gt;
          &lt;/Grid.RowDefinitions&gt;
          &lt;Rectangle Grid.Row="0" Margin="0,0,70,0" Fill="Transparent" Canvas.ZIndex="4"/&gt;
          &lt;ListView HorizontalContentAlignment="Stretch" Background="#FF6599CD" CanDragItems="False" CanReorderItems="False" Grid.Row="0"
                    ScrollViewer.VerticalScrollBarVisibility="Hidden" ScrollViewer.VerticalScrollMode="Disabled" 
                    ScrollViewer.HorizontalScrollBarVisibility="Hidden" ScrollViewer.HorizontalScrollMode="Disabled"&gt;
              &lt;ListView.ItemContainerStyle&gt;
                  &lt;Style TargetType="ListViewItem"&gt;
                      &lt;Setter Property="Template"&gt;
                          &lt;Setter.Value&gt;
                              &lt;ControlTemplate TargetType="ListViewItem"&gt;
                                  &lt;Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Height="40"&gt;
                                      &lt;Grid&gt;
                                          &lt;Grid.ColumnDefinitions&gt;
                                              &lt;ColumnDefinition Width="*" /&gt;
                                              &lt;ColumnDefinition Width="50" /&gt;
                                          &lt;/Grid.ColumnDefinitions&gt;
                                          &lt;TextBlock Text="Sample Text" FontSize="17" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,10,0,0" Canvas.ZIndex="10"/&gt;
                                          &lt;Image PointerPressed="Button_Click_1" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center" Source="Assets/arrw_right.png" Stretch="None" Margin="0,0,10,0"/&gt;
                                      &lt;/Grid&gt;
                                  &lt;/Border&gt;
                              &lt;/ControlTemplate&gt;
                          &lt;/Setter.Value&gt;
                      &lt;/Setter&gt;
                  &lt;/Style&gt;
              &lt;/ListView.ItemContainerStyle&gt;
              &lt;ListViewItem /&gt;
          &lt;/ListView&gt;
          &lt;ListView Grid.Row="1"
              IsHitTestVisible="True"
              CanDragItems="True" 
              CanReorderItems="True" 
              AllowDrop="True" 
              Name="ChildItems" 
              SelectionMode="None"
              IsItemClickEnabled="False"&gt;
              &lt;ListView.ItemTemplate&gt;
                  &lt;DataTemplate&gt;
                      &lt;local:CollapseUserControl CurrentItem="{Binding RelativeSource={RelativeSource Self}}" /&gt;
                  &lt;/DataTemplate&gt;
              &lt;/ListView.ItemTemplate&gt;
              &lt;ListView.ItemContainerStyle&gt;
                  &lt;Style TargetType="ListViewItem"&gt;
                      &lt;Setter Property="Padding" Value="0"/&gt;
                      &lt;Setter Property="Margin" Value="0"/&gt;
                  &lt;/Style&gt;
              &lt;/ListView.ItemContainerStyle&gt;
          &lt;/ListView&gt;
      &lt;/Grid&gt;
      &lt;TextBlock Name="ValueItem" Margin="0,0,0,0" Height="40" FontSize="36"&gt;&lt;/TextBlock&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p></p>
  
  <p>New error I get:</p>
  
  <pre><code>Failed to create a 'Windows.UI.Xaml.PropertyPath' from the text ''. 
  </code></pre>
  
  <p>Error comes from <code>&lt;local:CollapseUserControl CurrentItem="{Binding RelativeSource={RelativeSource Self}}" /&gt;</code>.</p>