title: How to implement a user defined class in WPF
body: <p>Hi I am trying to implement a user defined class in a WPF Window?</p>
  
  <p>The strange thing is that I already did this but this time it just does not work and I cannot find my error ...</p>
  
  <p>This is the class:</p>
  
  <pre><code>Namespace Controls
  
      Public Class WorkingPopup
          Inherits Primitives.Popup
  
          Public ReadOnly WorkingLabelProperty As DependencyProperty = DependencyProperty.Register("WorkingLabel", GetType(Label), GetType(WorkingPopup))
          Public ReadOnly WorkingProgressBarProperty As DependencyProperty = DependencyProperty.Register("WorkingProgressBar", GetType(ProgressBar), GetType(WorkingPopup))
  
          Private Property WorkingLabel As Label
              Get
                  Return GetValue(WorkingLabelProperty)
              End Get
              Set(value As Label)
                  SetValue(WorkingLabelProperty, value)
              End Set
          End Property
          Private Property WorkingProgressBar As ProgressBar
              Get
                  Return GetValue(WorkingProgressBarProperty)
              End Get
              Set(value As ProgressBar)
                  SetValue(WorkingProgressBarProperty, value)
              End Set
          End Property
  
          Public Sub New()
              MyBase.New()
  
              Placement = Primitives.PlacementMode.Center
              StaysOpen = True
              PopupAnimation = Primitives.PopupAnimation.Fade
  
              WorkingLabel = New Label With {.Visibility = Windows.Visibility.Visible, .Content = "Working", .ContentStringFormat = "{0} ..."}
              WorkingProgressBar = New ProgressBar With {.Height = 20, .Width = 200, .Margin = New Thickness(5)}
  
              Child = New Border
  
              With DirectCast(Child, Border)
                  .BorderBrush = SystemColors.ActiveBorderBrush
                  .Background = SystemColors.ControlLightLightBrush
                  .BorderThickness = New Thickness(1)
  
                  .Child = New StackPanel
  
                  With DirectCast(.Child, StackPanel)
                      .Children.Add(WorkingLabel)
                      .Children.Add(WorkingProgressBar)
                  End With
              End With
          End Sub
  
          'Some more irrelevant code
      End Class
  
  End Namespace
  </code></pre>
  
  <p>This is a bit of my XAML:</p>
  
  <pre><code>    &lt;RibbonWindow x:Class="MainWindow"
                xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:ctrl="clr-namespace:WpfApplication3.Controls"
                Title="MainWindow" Height="600" Width="800" WindowStartupLocation="CenterScreen" ResizeMode="CanResizeWithGrip"&gt;
  
      &lt;Grid&gt;
          &lt;Grid.RowDefinitions&gt;
              &lt;RowDefinition Height="Auto"/&gt;
              &lt;RowDefinition Height="*"/&gt;
              &lt;RowDefinition Height="Auto"/&gt;
          &lt;/Grid.RowDefinitions&gt;
  
          &lt;Grid.Children&gt;
              &lt;ctrl:WorkingPopup/&gt;
  
          &lt;/Grid.Children&gt;
      &lt;/Grid&gt;
  &lt;/RibbonWindow&gt;
  </code></pre>
  
  <p>Maybe it is because its monday morning ... but I don't get it ...</p>
  
  <p>Thanks</p>