gpt4 book ai didi

WPF - 选定的 ListView 项目更改字体大小

转载 作者:行者123 更新时间:2023-12-04 23:48:15 26 4
gpt4 key购买 nike

这是我的代码:

<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<ListBox ItemsSource="{Binding Persons}">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Border Background="White" BorderThickness="5" Name="Bd">
<Border.Style>
<Style TargetType="Border">
<Setter Property="BorderBrush" Value="White" />
</Style>
</Border.Style>
<StackPanel Orientation="Horizontal" >
<TextBlock Margin="10" Name="t1" Text="{Binding Name}"/>
<TextBlock Margin="10" Text="{Binding Age}"/>
</StackPanel>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Bd" Property="BorderBrush" Value="HotPink" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListBox.ItemContainerStyle>

</ListBox>
</Grid>

这就是 MouseOver 的样子: alt text

现在我想将鼠标悬停在上面以放大文本,我该怎么做?

最佳答案

只做这个?

<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Bd" Property="BorderBrush" Value="HotPink" />
<Setter TargetName="t1" Property="FontSize" Value="72" />
</Trigger>
</ControlTemplate.Triggers>

这将放大第一个文本 block - 您需要命名第二个文本 block 并在 TargetName 属性中使用新名称创建另一个 setter 以放大两者。

关于WPF - 选定的 ListView 项目更改字体大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3917704/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com