WPF: Custom control that binds its content to a label
- by nialsh
I want to write a custom control that's used like this:
<HorizontalTick>Some string</HorizontalTick>
It should render like this:
-- Some string -------------------------------------------
Here's my code:
<UserControl x:Class="WeatherDownloadDisplay.View.HorizontalTick"
         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" 
         mc:Ignorable="d" d:DesignWidth="348"
         Name="controlRoot">
<DockPanel LastChildFill="True">
    <UserControl VerticalAlignment="Center" BorderBrush="Black" BorderThickness="1" Width="10"/>
    <Label Content="???" />
    <UserControl VerticalAlignment="Center" BorderBrush="Black" BorderThickness="1"/>
</DockPanel>
It works except for the label binding.  Can someone help me fill in the question marks?  I thought about using a ContentPresenter but it seems like an inline binding would be best.
-Neal