我在ListBox上绑定可观察的集合。我在列表框项目上有数据tempate。它可以控制一个图像控制和SOM文本屏幕。

如果鼠标在某些列表框项目上,我想实现此行为:

  • 显示弹出/工具提示(一些带有控件的“矩形”)和listbox当前项目的绑定值。
  • 在项目数据模板中的文本框上,我有样式,我想在文本块中更改文本颜色,例如从黑色到绿色。

样式在这里:

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

SORY的英语,我有问题如何正确描述这种行为。我尝试了很多事情,但是它们中的任何一个都无法正常工作。

这是我的风格:

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

感谢所有帮助我的人。

有帮助吗?

解决方案

好吧,我找到了这个 杜里, 这篇文章,由MSDN 还有另一个 堆栈溢出的问题。基本上,这是:

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top