TextBlock myTextBlock = new TextBlock(); myTextBlock.Background = Brushes.Red; myTextBlock.SetCurrentValue(TextBlock.BackgroundProperty, Brushes.Blue); // This will output "Blue" Console.WriteLine(myTextBlock.Background);
TextBox myTextBox = new TextBox(); myTextBox.Text = "Hello, world!"; myTextBox.SetCurrentValue(TextBox.TextProperty, "Goodbye, world!"); // This will output "Goodbye, world!" Console.WriteLine(myTextBox.Text);In this example, we create a new instance of a TextBox and set its Text property to "Hello, world!". We then use the SetCurrentValue method to change the Text property to "Goodbye, world!", but only within the scope of the myTextBox object. When we output the value of myTextBox.Text, it will be "Goodbye, world!", but the overall value of the Text property is still "Hello, world!". Package library: PresentationFramework.dll