WPF binding OneWayToSource sets source property to “” when the DataContext is changed
问题 I have a OneWayToSource binding that is not behaving as I expected when I set the DataContext of the target control. The property of the source is being set to default instead of the value of the target control's property. I've created a very simple program in a standard WPF window that illustrates my problem: XAML <StackPanel> <TextBox x:Name="tb" Text="{Binding Path=Text,Mode=OneWayToSource,UpdateSourceTrigger=PropertyChanged}" TextChanged="TextBox_TextChanged"/> <Button Content="Set