title: How to use binding in WPF with Caliburn.Micro and with UserControl?
body: <p>I have created a UserControl with some fields. I would like to use it and bind data to these fields. Most of them are static values but the <code>DataValue</code> property comes from one property of the MainView.
  My code:</p>
  
  DataDisplayer.xaml
  
  <pre><code>&lt;UserControl x:Class="TabletMachineAccess.Controls.DataDisplayer"
               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:local="clr-namespace:TabletMachineAccess.Controls"
               xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
               x:Name="dataDisplayer"
               MaxHeight="100"
               mc:Ignorable="d"&gt;
  
      &lt;Border Height="auto"
              Margin="5"
              Padding="5,2,5,2"
              BorderBrush="Gray"
              BorderThickness="2"
              CornerRadius="5"&gt;
          &lt;StackPanel Orientation="Vertical"&gt;
              &lt;StackPanel Orientation="Horizontal"&gt;
                  &lt;TextBlock Text="{Binding DataType}" /&gt;
                  &lt;TextBlock Text=":" /&gt;
              &lt;/StackPanel&gt;
              &lt;Separator Style="{StaticResource BasicSeparator}" /&gt;
              &lt;TextBlock Margin="0,0,0,0"
                         HorizontalAlignment="Center"
                         FontWeight="Bold"
                         Text="{Binding Path=DataValue,
                                        ElementName=dataDisplayer}" /&gt;
              &lt;StackPanel HorizontalAlignment="Right" Orientation="Horizontal"&gt;
                  &lt;TextBlock FontWeight="ExtraLight" Text="(" /&gt;
                  &lt;TextBlock FontWeight="ExtraLight" Text="{Binding UnitText}" /&gt;
                  &lt;TextBlock FontWeight="ExtraLight" Text=")" /&gt;
              &lt;/StackPanel&gt;
          &lt;/StackPanel&gt;
      &lt;/Border&gt;
  &lt;/UserControl&gt;
  </code></pre>
  
  DataDisplayer.xaml.cs
  
  <pre><code>public partial class DataDisplayer : UserControl
  {
      public double DataValue
      {
          get { return (double)GetValue(DataValueProperty); }
          set { SetValue(DataValueProperty, value); }
      }
  
      // Using a DependencyProperty as the backing store for DataValue.  This enables animation, styling, binding, etc...
      public static readonly DependencyProperty DataValueProperty =
          DependencyProperty.Register("DataValue", typeof(double), typeof(DataDisplayer), new PropertyMetadata(9.9));
  
      public string DataType
      {
          get; set;
      }
  
      public string UnitText
      {
          get; set;
      }
  
      public DataDisplayer()
      {
          InitializeComponent();
          this.DataContext = this;
      }
  }
  </code></pre>
  
  I try to use it like this in MainView.xaml
  
  <pre><code> &lt;controls:DataDisplayer Grid.Row="1"
      Grid.Column="0"
      DataType="{x:Static res:Strings.PVUpper}"
      DataValue="{Binding PVUpper}"
      UnitText="{x:Static res:Strings.KgUnit}" /&gt;
  </code></pre>
  
  I have this in my MainViewModel.cs
  
  <pre><code>public double PVUpper { get; set; }
  </code></pre>
  
  <p>For those properties, which get data from the <code>res:Strings</code> works fine and display the correct values, but <code>DataValue</code> property always shows the default value of the DependencyProperty (9.9). The value of <code>PVUpper</code> changes in every second in the ViewModel so I would like to see this change on the View as well.</p>