I have several TextBoxess Labelsin my code that are implemented with the following XAML:
<DockPanel HorizontalAlignment="Right">
<TextBlock Foreground="Black" Padding="0,0,10,0">Serial Number:</TextBlock>
<TextBox Width="150" IsReadOnly="True" BorderBrush="Gainsboro" Height="20"></TextBox>
</DockPanel>
I can reduce the portion of the copied code by doing something like:
<DockPanel HorizontalAlignment="Right">
<TextBlock Style="{StaticResource CstmTextBoxLbl}">Serial Number:</TextBlock>
<TextBox Style="{StaticResource CstmTextBox}"></TextBox>
</DockPanel>
but it is still somewhat long. Is it possible to do something like:
<controls:CstmTextBox Style="{StaticResource CstmTextBox}" LabelText="Serial Number:" Text=""/>
Where CstmTextBoxwill I implement any XAML needed to get the same visual effect once, and I could access the text TextBlockand tag TextBoxin the code. For instance,
CstmTextBox textbox;
textbox.LabelText = "Serial Number:";
String some_text = textbox.Text;
textbox.Text = "....";
source
share