为WPF中TabControl的TabItem添加图片

默认状态下是一张图片,  选中时, 显示不同的图片. 

 

代码片段~

 

<TabControl Height="100" Name="tabControl1" Width="{Binding ElementName=ParentPanel, Path=Width}" > <TabItem Name="tabItem1"> <TabItem.Style> <Style TargetType="{x:Type TabItem}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type TabItem}"> <Image Name="img2Off" Width="84" Height="70" Source="images/admin_curriculum_on.gif" Margin="0,0,0,0" ></Image> <ControlTemplate.Triggers> <Trigger Property="IsSelected" Value="True"> <Setter TargetName="img2Off" Property="Source" Value="images/admin_curriculum_off.gif"></Setter> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> </TabItem.Style> <TextBlock>aaaaaaaaaaa</TextBlock> </TabItem> </TabControl>

你可能感兴趣的:(image,Path,WPF,setter,binding)