我有一个像下面那样声明的ListBox
。问题是,在项目定义中,我有很多带有网格和元素的内容。我想仅更改项目中一个图像的可见性,使其仅在选择该元素本身时可见。
我成功地更改了项目被选中时的背景和整体外观,但我无法访问内部元素 :(
<ListBox stuff stuff stuff>
<ListBox.ItemTemplate>
<DataTemplate DataType="local:Patient">
<grids , borders, things, stuff
<Image Name="image1" source opacity stuff/>
</ grids bordes and design in general>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}">
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Foreground" Value="White"/>
<!--HERE I WANT TO CHANGE VISIBILITY OF THE IMAGE-->
</Trigger>
</Style.Triggers>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.Template>
<!-- some other styles when deselected and other things -->
</ListBox.Template>
</ListBox>
我尝试使用:
<Setter TargetName="physiciansSettinsImage" Property="Visibility" Value="Visible"/>
但是不能在样式设置器上设置。有什么线索吗?
整个设计相当复杂,因此我希望尽可能避免重新编码。