Question

Je lie la collection observable sur listBox. J'ai tempate de données sur le point listbox. Il Consit un contrôle d'image et som textBlock.

Si est la souris sur sur certains point de listBox Je voudrais obtenir ce comportement:

  • Afficher PopUp / info-bulle (certains "rectangle" avec des commandes) et lier les valeurs de courant listBox article.
  • Et sur textBox dans les données article I ont un style modèle, je voudrais la couleur du texte de changement textBlock, par exemple du noir au vert.

Le style est ici:

        <Style x:Key="FriedNickStyle" TargetType="TextBlock">
            <Setter Property="Margin" Value="2,2,2,2"/>
            <Setter Property="FontSize" Value="13"/>
            <Setter Property="FontWeight" Value="Medium"/>
            <Setter Property="Foreground" Value="Black"/>
        </Style>

pour mon anglais Sory, j'ai problème comment décrire ce comportement correct. J'essaie beaucoup de chose, mais aucun d'entre eux ne fonctionne pas bien.

Voici ce mon style:

     <DataTemplate x:Key="FriendListBoxItemTemplate">
                <Grid Name="RootLayout">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="0.3*"></ColumnDefinition>
                        <ColumnDefinition Width="*"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="60"></RowDefinition>
                    </Grid.RowDefinitions>
                    <Image Margin="4,4,4,2" Grid.Column="0">
                        <Image.Source >
                            <MultiBinding Converter="{StaticResource avatarConverter}">
                                <Binding Path="ProfilePhoto"></Binding>
                                <Binding Path="StatusInfo.IsLogged"></Binding>
                            </MultiBinding>
                        </Image.Source>
                    </Image>
                    <Grid  Grid.Column="1">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"></RowDefinition>
                        </Grid.RowDefinitions>
                    <TextBlock 
                                       Text="{Binding Path=Nick}" 
                                       Style="{StaticResource FriedNickStyle}"
                                       Grid.Column="0" Grid.Row="0">
                    </TextBlock>
                    </Grid>
                </Grid>
                <DataTemplate.Triggers>
                    <Trigger Property="IsMouseOver" Value="True">
                        <!--SHOW SOME POP UP WINDOW and bind properties from ITEM (VALUE)-->
<!--Change color of textBlock-->
                    </Trigger>
                </DataTemplate.Triggers>
            </DataTemplate>

Merci tous ceux qui me aider.

Était-ce utile?

La solution

Eh bien, je l'ai trouvé cette turorial , cet article, par le MSDN et un autre pile question de débordement . En gros, voici comment:

<Popup Margin="10,10,0,13"
    Name="Popup1"
    HorizontalAlignment="Left"
    VerticalAlignment="Top"
    Width="194"
    Height="200"
    IsOpen="True">                      // change this to open it

   <TextBlock Name="McTextBlock" Background="LightBlue" >
        This is popup text
   </TextBlock>

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top