显示“弹出窗口"何时将鼠标悬停在listBox项上 [英] Show "pop up window" when is mouser over listBox item
本文介绍了显示“弹出窗口"何时将鼠标悬停在listBox项上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在listBox上绑定了可观察的集合.我在列表框项目上有数据模板.它包含一个图像控件和一个textBlock.
I bind observable collection on listBox. I have data tempate on listbox item. It consit one image control and som textBlock.
如果将鼠标悬停在某些listBox项上,我想实现此行为:
If is mouse over on some listBox item I would like achieve this behavior:
- 显示PopUp/ToolTip(带有控件的一些矩形")并绑定listBox当前项目中的值.
- 在项目数据模板中的textBox上,我有样式,我想更改textBlock中文本的颜色,例如从黑色更改为绿色.
样式在这里:
<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 for my english, I have problem how describe this behavior correct. I try many thing but any of them doesn’t work good.
这是我的风格:
<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>
感谢所有帮助我的人.
推荐答案
好吧,我发现了这个土耳其语,堆栈溢出的问题. 基本上,方法如下:
Well, I found this turorial, this article, by the MSDN and another stack overflow's question. Basically, here's how:
<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>
这篇关于显示“弹出窗口"何时将鼠标悬停在listBox项上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文