TextBlock textBlock = new TextBlock(); textBlock.SetValue(TextBlock.ForegroundProperty, Brushes.Red);
ListBoxItem listBoxItem = new ListBoxItem(); listBoxItem.SetValue(ListBoxItem.WidthProperty, 100);This code sets the Width property of the ListBoxItem control to 100. These examples are part of the WPF library in the .NET Framework.