このコードをクリーンアップする方法を学びたいと思っています。c#で定義された「スタイル」を適用する方法はありますか? 私は新しく、プログラミングを強化する方法を探しています。マージン、最大値、向き、ステップ頻度、目盛り頻度、目盛りの配置、および各スライダーへの遷移をより簡潔な方法で定義できるようにしたいと考えています。
//Slider 1
Slider Slider_1 = new Slider();
Slider_1.SetValue(Grid.ColumnProperty, 0);
Slider_1.Margin = new Thickness(30, 12, 0, 0);
Slider_1.Orientation = Orientation.Vertical;
Slider_1.Maximum = 10;
Slider_1.StepFrequency = 0.25;
Slider_1.TickFrequency = 0.25;
Slider_1.TickPlacement = TickPlacement.Outside;
Slider_1.Transitions = new TransitionCollection();
Slider_1.Transitions.Add(new EntranceThemeTransition() { });
//Slider 2
Slider Slider_2 = new Slider();
Slider_2.SetValue(Grid.ColumnProperty, 1);
Slider_2.Margin = new Thickness(30, 12, 0, 0);
Slider_2.Orientation = Orientation.Vertical;
Slider_2.Maximum = 10;
Slider_2.StepFrequency = 0.25;
Slider_2.TickFrequency = 0.25;
Slider_2.TickPlacement = TickPlacement.Outside;
Slider_2.Transitions = new TransitionCollection();
Slider_2.Transitions.Add(new EntranceThemeTransition() { });
//Slider 3
Slider Slider_3 = new Slider();
Slider_3.SetValue(Grid.ColumnProperty, 2);
Slider_3.Margin = new Thickness(30, 12, 0, 0);
Slider_3.Orientation = Orientation.Vertical;
Slider_3.Maximum = 10;
Slider_3.StepFrequency = 0.25;
Slider_3.TickFrequency = 0.25;
Slider_3.TickPlacement = TickPlacement.Outside;
Slider_3.Transitions = new TransitionCollection();
Slider_3.Transitions.Add(new EntranceThemeTransition() { });
//Slider 4
Slider Slider_4 = new Slider();
Slider_4.SetValue(Grid.ColumnProperty, 3);
Slider_4.Margin = new Thickness(30, 12, 0, 0);
Slider_4.Orientation = Orientation.Vertical;
Slider_4.Maximum = 10;
Slider_4.StepFrequency = 0.25;
Slider_4.TickFrequency = 0.25;
Slider_4.TickPlacement = TickPlacement.Outside;
Slider_4.Transitions = new TransitionCollection();
Slider_4.Transitions.Add(new EntranceThemeTransition() { });