Hi @Karl Albright .
Welcome Microsoft Q&A.
You could update your code as follows.
With ContentPresenter, most times, this does the job:
<ContentPresenter />
The default ContentSource is "Content". That means it'll look at the Content property of the templated parent and it'll take whatever it finds there for its own content.
<StackPanel>
<local:MyControl Label="Approved voltage" Unit="V" Height="30" Width="200" HorizontalAlignment="Left" VerticalAlignment="Top">
<local:MyControl.InnerContent>
<TextBox Text="{Binding InputValue,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}"/>
</local:MyControl.InnerContent>
</local:MyControl>
<TextBlock Text="{Binding Path=InputValue,StringFormat=[{0}],UpdateSourceTrigger=PropertyChanged}" Height="30" Width="200" HorizontalAlignment="Left" VerticalAlignment="Top"/>
</StackPanel>
<Style TargetType="{x:Type local:MyControl}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:MyControl}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition MinWidth="50" Width="5*" />
<ColumnDefinition Width="5*" />
<ColumnDefinition MinWidth="28" Width="2*" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{TemplateBinding Label}" VerticalAlignment="Center" HorizontalAlignment="Left" FontSize="10" Foreground="Black" />
<ContentPresenter Grid.Column="1" Height="20" Content="{TemplateBinding InnerContent}"/>
<TextBlock Grid.Column="2" Text="{TemplateBinding Unit}" Margin="5 0 0 0" VerticalAlignment="Center" HorizontalAlignment="Left" FontSize="20" Foreground="Black"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Best Regards.
Jiachen Li
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.