我正在使用MahApps TabControl。如果我從xaml添加項目,我可以設置「CloseButtonEnabled = true」,並顯示關閉按鈕,當我嘗試綁定ItemSource時,關閉按鈕不會出現。任何想法,我怎麼能解決這個問題?Mahapps TabControl,無法設置CloseButtonEnabled = true時使用ItemSource = {Binding ..}
這裏是我的示例代碼:
<Window.Resources>
<Style BasedOn="{StaticResource MetroTabItem}" TargetType="{x:Type Controls:MetroTabItem}">
<Setter Property="Controls:ControlsHelper.HeaderFontSize" Value="15"/>
<Setter Property="Foreground" Value="Red"/>
<Setter Property="CloseButtonEnabled" Value="True"/>
</Style>
</Window.Resources>
<Controls:MetroTabControl ItemsSource="{Binding AvailableFiles}" SelectedIndex="{Binding SelectedIndex}" Grid.Row="1" >
<Controls:MetroTabControl.ItemTemplate >
<DataTemplate>
<TextBlock Text="{Binding Title}" />
</DataTemplate>
</Controls:MetroTabControl.ItemTemplate>
</Controls:MetroTabControl>
是的是的!它現在有效!謝謝。 – niks