【发布时间】:2023-03-29 07:27:01
【问题描述】:
我不知道这是否可能,我对 wpf 了解不多。
我有这个带有 2 个 TabItems 的 TabControl,每个 TabItems 都包含一个 TextBox
<TabControl>
<TabItem Style="{StaticResource TabStyle}" Header="TabItem1">
<TextBox/>
</TabItem>
<TabItem Style="{StaticResource TabStyle}" Header="TabItem2">
<TextBox/>
</TabItem>
</TabControl>
我对 TabItem 有这种风格
<Style x:Key="TabStyle" TargetType="{x:Type TabItem}">
<Style.Triggers>
<Trigger Property="IsFocused" Value="true">
<Setter Property="Text" Value="tab is focused"/> <!--Point this setter to the textbox inside the tab item -->
</Trigger>
<Trigger Property="IsFocused" Value="false">
<Setter Property="Text" Value="tab is focused"/><!--Point this setter to the textbox inside the tab item -->
</Trigger>
</Style.Triggers>
</Style>
如果我的选项卡项只有一个 TextBox 类型的控件,是否可以从选项卡项触发器内部的设置器中修改该文本框,如何在不使用名称的情况下找到 TextBox 类型的子项?
【问题讨论】: