Answer the question
In order to leave comments, you need to log in
How to set the TemplateBinding correctly?
There is such a Template
<ControlTemplate x:Key="TextBoxFieldTemplate" TargetType="{x:Type TextBox}">
<Grid Height="{TemplateBinding Height}">
<TextBox
Foreground="{TemplateBinding Foreground}"
FontFamily="{TemplateBinding FontFamily}"
BorderThickness="{TemplateBinding BorderThickness}"
BorderBrush="{TemplateBinding BorderBrush}"
Padding="{TemplateBinding Padding}"
FontSize="16"
Height="30"
Text="{TemplateBinding Text}"/>
<Image Source="C:\Users\user\Downloads\usr.png" Width="14" Height="14" HorizontalAlignment="Left" />
</Grid>
</ControlTemplate>
<Image />
how do I pass the value to the Source, how to correctly write the TemplateBinding to such elements. <image />
the same way?<TextBox
Tag="C:\Users\user\Downloads\usr.svg"
Padding="20 4 0 0"
Foreground="#ccc"
Text="username"
BorderThickness="0 0 0 1"
BorderBrush="#ccc"
Template="{StaticResource TextBoxFieldTemplate}"
FontFamily="/Fonts/#Montserrat Light" Margin="0,50,0,100" TextChanged="TextBox_TextChanged_1">
</TextBox>
Answer the question
In order to leave comments, you need to log in
1. Use AttachedDependencyProperty (see the last answer https://stackoverflow.com/questions/7309623/pass-p... )
2. Implement your improved TextBox as a user control and the corresponding class and add the DependencyProperty you need already. One of the advantages here is that, if necessary, you can, if necessary, override some control methods to change the behavior, for example.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question