2010-10-12 39 views
2

ListView項,這是我的代碼:WPF - 在選定的更改字體大小

<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> 

這是鼠標懸停的樣子: alt text

現在我想將鼠標放在要放大文本,我怎樣才能做到這一點 ?

回答

0

只是這樣做?

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

這將擴大第一文本塊 - 您需要命名第二個,並與新名稱的另一個二傳手在targetName屬性放大兩者。