Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7192623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:58:45+00:00 2026-05-28T19:58:45+00:00

I have XAML: <TextBlock Text=Param 1 name Margin=6,6,0,0></TextBlock> <TextBox Text={Binding Param1Value, UpdateSourceTrigger=PropertyChanged} Margin=6,6,0,0></TextBox> <TextBlock

  • 0

I have XAML:

<TextBlock Text="Param 1 name" Margin="6,6,0,0"></TextBlock>
<TextBox Text="{Binding Param1Value, UpdateSourceTrigger=PropertyChanged}" Margin="6,6,0,0"></TextBox>

<TextBlock Text="Param 2 name" Margin="6,6,0,0"></TextBlock>
<TextBox Text="{Binding Param2Value, UpdateSourceTrigger=PropertyChanged}" Margin="6,6,0,0"></TextBox>

...

<TextBlock Text="Param N name" Margin="6,6,0,0"></TextBlock>
<TextBox Text="{Binding ParamNValue, UpdateSourceTrigger=PropertyChanged}" Margin="6,6,0,0"></TextBox>

How can be optimized this code to prevent copy-paste?
Control, Style, ContentControl or DataTemplate?

I can use Style to reuse margin, but how can be reused structure of this pairs TexBlock and TextBox?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T19:58:47+00:00Added an answer on May 28, 2026 at 7:58 pm

    Make a UserControl with two properties (E.g., Caption and Text) and bind the TextBlock to the Caption and the TextBox to the Text property.

    You could also use a Templated Control if you want to allow the designer to create a custom templates so he can fully control the UI design.

    UserControl vs. Custom/Templated Control (read the entire thread for maximum benefit):

    Well the difference between user control and custom control is that If
    you have a portion of views or UI which will be used repeatedly in
    your own project, using UserControl is a much simpler and preferred
    way, but if you have a portion of UI and functionality which you
    believe will be used aross different projects, then using custom
    control is the right approach.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following XAML: <TextBlock Text={Binding ElementName=EditListBox, Path=SelectedItems.Count} Margin=0,0,5,0/> <TextBlock Text=items selected> <TextBlock.Style>
I have the following Xaml in a Window ( ArtistInfo ): <Grid> <TextBlock Text={Binding
I have this code in MainPage.xaml: <controls:PivotItem Header=first> <ListBox x:Name=MyListBox Margin=0,0,-12,0 ItemsSource={Binding ListBoxItem}> <ListBox.ItemTemplate>
Lets say I have some XAML like this: <StackPanel> <TextBlock Text=Blah Blah Blah />
I have the following layout in XAML: <StackPanel Height=40> <TextBlock TextWrapping=Wrap TextTrimming=WordEllipsis Margin=0,10,0,10 LineHeight=18
I have next XAML <ComboBox Margin=5 Width=150 Name=languageComboBox> <ComboBoxItem Content=Russian Tag =1 IsSelected=True/> <ComboBoxItem
I have the following listpicker in my XAML; <toolkit:ListPicker Name=CategoryPicker ItemsSource={Binding Category} CacheMode=BitmapCache FullModeHeader={Binding
I have a XAML window with multiple TextBoxes, each with a corresponding TextBlock tag
I have a .xaml file and a .cs file that share value with Binding.
I have a xaml file with this code: <GridViewColumn x:Name=lvCol3 Header=Quantità Width=120> <GridViewColumn.CellTemplate> <DataTemplate>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.