StackPanel myStackPanel = new StackPanel(); myStackPanel.SetValue(StackPanel.BackgroundProperty, Brushes.Black);
StackPanel myStackPanel = new StackPanel(); myStackPanel.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);This code creates a new StackPanel and sets its orientation to horizontal using SetValue method. Package library: The System.Windows.Controls.StackPanel class is part of the WPF (Windows Presentation Foundation) library in .NET framework. The namespace for this class is System.Windows.Controls.