Reputation: 6039
I'm trying to set the HorizontalAlignment
property of a WPF TabControl
in the code-behind file (not in XAML), but there doesn't seem to be any way to do it. Is there a way to set this property in code without creating a style for the entire control?
Upvotes: 1
Views: 3482
Reputation: 6039
The actual problem was that Visual Studio was referencing System.Windows.Forms.TabControl
instead of System.Windows.Controls.TabControl
. The WPF version has a HorizontalAlignment
property, whereas the Winforms version does not.
Forcing it to create a System.Windows.Controls.TabControl
fixed the problem.
Upvotes: 0
Reputation: 2469
You need to name your TabControl, then you will be able to reference it in code behind. Like this:
<TabControl Name="MyTabControl" />
this.MyTabControl.HorizontalAlignment = HorizontalAlignment.Left;
Upvotes: 6