1

ListBox コントロールが文字列のリストにバインドされている場合、ListBoxItem のツールチップを表示するにはどうすればよいですか。以下は、ConcernedConditions が List タイプである、私の ListBox のソース コードです。

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

1 に答える 1

5

リストボックスの項目テンプレートのスタイルを設定し、そこにテキストブロックを配置してから、ツールチップ プロパティを使用できますか?

<ListBox ItemsSource="{Binding Strings}">
    <ListBox.ItemTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding}" ToolTip="Here is a tooltip"/>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>
于 2012-11-06T15:48:35.200 に答える