开发者

WPF combo box Image as tooltip

开发者 https://www.devze.com 2023-01-20 23:11 出处:网络
I am creating a WPF application which contains a combobox.When there is a mouse over on the combo box, suppose the combo contains the strings apple and orange, I need to show the corresponding image a

I am creating a WPF application which contains a combobox.When there is a mouse over on the combo box, suppose the combo contains the strings apple and orange, I need to show the corresponding image as a tooltip.

I got a sample application from the following link.

http://diptimayapatra.wordpress.com/2010/03/05/image-in-tooltip-in-wpf/

I understood the code behind, but there are some doubts in xaml portion. How can we use the ItemsPanelTemplate? Where I need to place these portion?

I tried the following...

<Window>
<Styles.开发者_开发知识库..>
</Styles>
       <Grid> 
            <ItemPanelTemplate....>
            </ItemPanelTemplate>
            <Listbox>
            </Listbox>
...

</Window>

But I can't. I am a beginer in WPF.Please help.


It should be in stryles for combobox targettype

<Style TargetType="ComboBox">
  <Setter Property="ItemsPanel">
    <Setter.Value>
      <ItemsPanelTemplate> </ItemsPanelTemplate>
</Setter.Value>
</Setter>
</Style>

The other way if you anly want that particular combobox to have the specified style then you can go for

<ComboBox>
    <ComboBox.ItemsPanel>
            <ItemsPanelTemplate>
                <VirtualizingStackPanel />
            </ItemsPanelTemplate>
        </ComboBox.ItemsPanel>
</ComboBox>
0

精彩评论

暂无评论...
验证码 换一张
取 消