2012-11-06 15 views
1

的列表中,我們怎樣才能顯示一個ListBoxItem的提示時,ListBox控件綁定到字符串列表。下面是我的ListBox的源代碼,其中ConcernedConditions是列表類型。工具提示ListBoxItem的當綁定到字符串

<ListBox ItemsSource="{Binding ConcernedConditions}" Style="{StaticResource CustomStyle}"> 
    <ListBox.ItemContainerStyle> 
     <Style TargetType="{x:Type ListBoxItem}"> 
      <Setter Property="Template"> 
       <Setter.Value> 
        <ControlTemplate TargetType="{x:Type ListBoxItem}"> 
         <ContentPresenter /> 
        </ControlTemplate> 
       </Setter.Value> 
      </Setter> 
     </Style> 
    </ListBox.ItemContainerStyle> 
</ListBox> 

回答

5

您可以設置列表框的項目模板,並在其中放置一個文本塊,然後使用它的工具提示屬性?

<ListBox ItemsSource="{Binding Strings}"> 
    <ListBox.ItemTemplate> 
     <DataTemplate> 
      <TextBlock Text="{Binding}" ToolTip="Here is a tooltip"/> 
     </DataTemplate> 
    </ListBox.ItemTemplate> 
</ListBox> 
+0

哇...這確實是一個很容易解決。謝謝安迪:) – Irfan

相關問題