How to make this code more efficient?

Dan*_*986 4 c# wpf properties

As i am not very advanced in C# yet, I try to learn how to make my code more efficient. I stored a lot of strings in some of the properties.

At the start of the application, i load all the seperatie properties into the textboxes. I now ise this code to load them all:

private void LoadStoredStrings()
{
    txtT1S1.Text = Properties.Settings.Default.strT1L1;
    txtT1S2.Text = Properties.Settings.Default.strT1L2;
    txtT1S3.Text = Properties.Settings.Default.strT1L3;
    txtT1S4.Text = Properties.Settings.Default.strT1L4;
    txtT1S5.Text = Properties.Settings.Default.strT1L5;
    txtT1S6.Text = Properties.Settings.Default.strT1L6;
    txtT1S7.Text = Properties.Settings.Default.strT1L7;
    txtT1S8.Text = Properties.Settings.Default.strT1L8;
    txtT1S9.Text = Properties.Settings.Default.strT1L9;
    txtT1S10.Text = Properties.Settings.Default.strT1L10;
}
Run Code Online (Sandbox Code Playgroud)

显而易见,我可以看到每个存储的属性结束的逻辑T1L1也适合以txt结尾的txt T1S1.我只知道这应该以比我现在更优雅和坚实的方式完成.有人能把我推向正确的方向吗?

bli*_*eis 5

您可以将属性直接绑定到文本框

<UserControl xmlns:Properties="clr-namespace:MyProjectNamespace.Properties" >


<TextBox Text="{Binding Source={x:Static Properties:Settings.Default}, Path=strT1L1, Mode=TwoWay}" />
Run Code Online (Sandbox Code Playgroud)