各 ListBoxItem に画像とテキストを表示するために、ウィンドウの ListBox をオーバーライドしましたが、表示されるテキストの内容をフィルター処理する必要があります。それを機能させます。
<Setter Property="ItemContainerStyle">
<Setter.Value>
<!-- Simple ListBoxItem - This is used for each Item in a ListBox. The item's content is placed in the ContentPresenter -->
<Style TargetType="{x:Type ListBoxItem}">
<Setter Property="SnapsToDevicePixels" Value="true"/>
<Setter Property="OverridesDefaultStyle" Value="true"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<Grid SnapsToDevicePixels="true">
<Border x:Name="Border">
<Grid Height="40">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Image
Source="{Binding Path=ThumbnailImage}"
Height="30"
Width="30"
Grid.Column="0"/>
<Label
x:Name="Text"
Content="{TemplateBinding DisplayMemberPath}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
VerticalContentAlignment="Center"
HorizontalAlignment="Stretch"
Grid.Column="1"
Height="40"/>
</Grid>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="true">
<Setter Property="FontWeight" Value="Bold" TargetName="Text"/>
<Setter Property="Foreground" Value="White" TargetName="Text"/>
<Setter Property="Background" Value="Blue" TargetName="Border"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Setter.Value>
</Setter>
これは私が自分のスタイルに使用しているコードであり、これは私が動作できない行でした:
Content="{TemplateBinding DisplayMemberPath}"
「ListBoxItem」タイプの静的メンバー「DisplayMemberPathProperty」が見つかりません
誰かが私を正しい方向に向けることができますか?