Cela va obtenir ce que vous entrez dans votre boîte de texte à votre propriété dans le codebehind. En fonction de la taille de votre projet, je considérerais MVVM pour pousser le code vers le ViewModel, puis dans le UserControl, vous spécifieriez this.DataContext = une instance de votre ViewModel.
Xaml:
<UserControl x:Class="SilverlightApplication1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<StackPanel>
<TextBox Text="{Binding Foo,Mode=TwoWay}"/>
<Button Content="Click" Click="Button_Click"/>
</StackPanel>
</UserControl>
code Derrière:
public partial class MainPage : UserControl
{
public string Foo { get; set; }
public MainPage()
{
InitializeComponent();
this.DataContext = this;
}
}