पर होवर करता है, मैंने टैबलेट को पृष्ठभूमि में xaml में सेट किया है, लेकिन जब मैं इसे चलाता हूं और उस पर होवर करता हूं या इसे चुनता हूं तो यह डिफ़ॉल्ट ग्रेश को देखता है। यह केवल तब दिखाता है जब अन्य टैबिटम चयनित होता है। मैं इसे हर समय लाल कैसे रखूं। धन्यवाद!डब्ल्यूपीएफ - टैबिटेम पृष्ठभूमि रंग बदलता है जब टैबिटम चयनित होता है या
13
A
उत्तर
28
Here is example of TabItem ControlTemplate
अपने संसाधनों के लिए इसे कॉपी और सेट भी आप पृष्ठभूमि के रूप में लाल रंग की जरूरत है।
नमूना
<Window x:Class="TestCustomTab.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300">
<Window.Resources>
<SolidColorBrush x:Key="RedBrush" Color="Red"/>
<SolidColorBrush x:Key="SolidBorderBrush" Color="#888" />
<SolidColorBrush x:Key="GreenBrush" Color="Green" />
<SolidColorBrush x:Key="DisabledBackgroundBrush" Color="#EEE" />
<SolidColorBrush x:Key="DisabledBorderBrush" Color="#AAA" />
<SolidColorBrush x:Key="DisabledForegroundBrush" Color="#888" />
<Style TargetType="{x:Type TabItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabItem}">
<Grid>
<Border
Name="Border"
Margin="0,0,-4,0"
Background="{StaticResource RedBrush}"
BorderBrush="{StaticResource SolidBorderBrush}"
BorderThickness="1,1,1,1"
CornerRadius="2,12,0,0" >
<ContentPresenter x:Name="ContentSite"
VerticalAlignment="Center"
HorizontalAlignment="Center"
ContentSource="Header"
Margin="12,2,12,2"
RecognizesAccessKey="True"/>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Panel.ZIndex" Value="100" />
<Setter TargetName="Border" Property="Background" Value="{StaticResource GreenBrush}" />
<Setter TargetName="Border" Property="BorderThickness" Value="1,1,1,0" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="Border" Property="Background" Value="{StaticResource DisabledBackgroundBrush}" />
<Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource DisabledBorderBrush}" />
<Setter Property="Foreground" Value="{StaticResource DisabledForegroundBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
<Grid>
<TabControl>
<TabItem Header="MyTabItem" />
<TabItem Header="MyTabItem" />
</TabControl>
</Grid>
</Window>
परीक्षण WPF परियोजना और Window1.xaml कोड के बजाय पेस्ट नमूना कोड बनाएँ।
क्या आप मुझे एक त्वरित उदाहरण दिखा सकते हैं। धन्यवाद! – TCoder
नमूना के साथ अद्यतन की जांच करें। –
महान काम करता है! धन्यवाद! – TCoder