2010-10-12 5 views
2

ceci est mon code:WPF - ListView article sur le changement sélectionné Taille de la police

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

Et voici comment MouseOver ressemble: alt text

Maintenant, je veux la souris pour agrandir le texte, Comment puis je faire ça ?

Répondre

0

Juste faire ceci?

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

Cela agrandira la première textblock - vous devez nommer le second et faire un autre compositeur avec le nouveau nom dans la propriété TargetName pour agrandir les deux.

Questions connexes