【发布时间】:2013-05-15 11:39:24
【问题描述】:
在我的应用程序中,我最近尝试在外观方面对其进行优化,因此我尝试使用MahApps.Metro。但是我遇到了一些障碍。
在我的应用程序中,我有一个tabcontrol,我使用了一个style,如下所示;
<Page.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!--Resource dictionary for mahapps. -->
</ResourceDictionary.MergedDictionaries>
<Style TargetType="{x:Type TabItem}">
<Setter Property="HeaderTemplate">
<Setter.Value>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<!-- FormName is the name of the ViewModel-->
<TextBlock Text="{Binding FormName}" VerticalAlignment="Center" Margin="2" />
</StackPanel>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding IsValid}"
Value="False">
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
</Page.Resources>
<!-- The itemsource that is bound to is a ObservableCollection of Forms that are used to validate for a Progress bar, It uses the ViewModels-->
<TabControl x:Name="tabcontrol"
Grid.Row="1"
ItemsSource="{Binding Forms}"
SelectedIndex="0" BorderBrush="Black" />
显然,这不是使用MahApps.Metro tabcontrol。但是,在tabcontrol 的style 中,我将TargetType 更改为以下内容,但这会导致Page 中的所有内容增加其大小并将两个选项卡内容有效地合并为一个;
<Style TargetType="{x:Type Controls:MetroTabItem}" BasedOn="{StaticResource MetroTabItem}">
如果能帮助我实施 MahApps.Meto tab control 并清除我做错的事情,我们将不胜感激。干杯。
【问题讨论】:
标签: c# wpf xaml styles mahapps.metro