0
TL; DR - バインディングエラーが発生しました。疲れた目は物事を逃す。ViewModelプロパティへのテンプレート付きリストボックスの画像のバインド
私は、ListBoxをコンテナとして使用して複数選択のCheckBoxリストを実装しました。今度は、リストの各チェックボックスの横に、表示可能性がViewModelプロパティにバインドされている画像を表示したいが、これを行うのが難しい。
私のスタイルは私のリストボックスは次のように定義されて
<Grid.Resources>
<Style x:Key="ListBoxCheckStyle" TargetType="ListBox">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBox">
<ItemsPresenter HorizontalAlignment="Left" VerticalAlignment="Top"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<ItemsPanelTemplate x:Key="ListBoxCheckStyleItemsPanelTemplate">
<StackPanel />
</ItemsPanelTemplate>
<Style x:Key="ListBoxItemCheckStyle" TargetType="ListBoxItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<StackPanel Orientation="Horizontal">
<ChimeControls:CheckBox
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
Margin="0,0,10,0"
IsChecked="{Binding IsSelected, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"/>
<Image
Width="16"
Height="16"
VerticalAlignment="Center"
Source="{StaticResource OccurredStatusTypeImageSource}"
Visibility="{Binding HasConsentCondition, Converter={StaticResource BoolToVisibilityConverter}, FallbackValue=Collapsed}"
HorizontalAlignment="Right"
Margin="10,0,10,0" />
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Grid.Resources>
:
<ListBox
x:Name="objectivesListBox"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Style="{StaticResource ListBoxCheckStyle}"
ItemsPanel="{StaticResource ListBoxCheckStyleItemsPanelTemplate}"
ItemContainerStyle="{StaticResource ListBoxItemCheckStyle}"
ItemsSource="{Binding ObjectivesList}"
DisplayMemberPath="mgt_plan_obj_name"
AttachedProperties:ListBoxSelectedItems.Items="{Binding SelectedObjectives, Mode=TwoWay}"
SelectionMode="Multiple"/>
私のイメージとはいえ表示されず、プロパティのゲッターは、可視性が呼び出されることはありませんにバインドされていません。私は何が欠けていますか?
XAMLが正常に見えます。実行時に出力ウィンドウにバインディングエラーがありますか?あなたが 'BoolToVisibilityConverter'にブレイブポイントを置くと、それがヒットしていますか? 'OccurredStatusTypeImageSource'は正しいイメージを指していますか? – nemesv
ガー、私は出力ウィンドウを見て、誓いを立てることができました。私はそれが朝の新鮮な目がもたらすものだと思う。ご協力いただきありがとうございます。 –