나는 WPF와 장난 그리고 난 다음 문서 보았다 WPF ListView Inactive Selection Color목록보기는 선택 색상
나는 비슷한 싶지합니다. 선택 될 때 listviewitem 주위에 테두리를 놓고 배경색을 변경하지 않으려합니다. 내가 원하는 이유는 색으로 구분 된 목록보기를 원하고 선택되었을 때 여전히 색을보고 싶지만 주변에 테두리가있는 것으로 선택되어 있다는 것을 알고 싶습니다.
아이디어가 있으십니까?
UPDATE :
내가 아래에 대답을 시도하고 나에게 절반 방법을 가지고, 그것은 ListViewItem이 주위에 테두리를 넣어 않지만 내 배경 색상을 무시합니다.
<Style x:Key="MyListViewItemStyle" TargetType="{x:Type ListViewItem}">
<Setter Property="Background" Value="{Binding SourceType, Converter={StaticResource SourceGroupConverter}}"/>
<Setter Property="Template">
...//Same as above
</Setter>
</Style>
모두 시도 그냥 흰색 (또는 투명 그렇게하지의 배경을 설정 : 다음이 시도
<Style x:Key="SourceListView" TargetType="{x:Type ListViewItem}">
<Setter Property="Background" Value="{Binding SourceType, Converter={StaticResource SourceGroupConverter}}"/>
</Style>
<Style x:Key="MyListViewItemStyle" TargetType="{x:Type ListViewItem}" BasedOn="{StaticResource SourceListView}" >
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListViewItem}">
<Border
x:Name="Border"
BorderBrush="Transparent"
BorderThickness="1">
<GridViewRowPresenter Columns="{TemplateBinding GridView.ColumnCollection}" Content="{TemplateBinding Content}"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="true">
<Setter TargetName="Border" Property="BorderBrush" Value="Black"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
: 난 내가 시도 올바른 구문합니다 (BasedOn을 주목하라)를 얻을 수 없다 알고있다). 나는 그것이 구문 일 뿐이라는 것을 알고 올바른 방향으로 다른 쪽을 주셔서 감사합니다.
내가 이것을 시도하고는 테두리를 설정 않았다,하지만 배경색 내 구문이 무시되고있는 것 같다. 더 이상 도움이 필요합니까? 또 다른 점은 위 스타일로 listviewitem의 비 공백 영역 (예 : 열의 내용을 클릭)을 클릭하면 listview 만 선택된다는 것입니다. 왜 이런거야? – Jose
내 코드 예제를 업데이트했습니다. ListBaseItem의 background 속성에 테두리의 Background 속성에 TemplateBinding을 추가했습니다. 네가 선택으로 설명하는 것처럼 왜 행동하는지 모르겠다. 내 예제를 시도하고 행에 빈 공간을 클릭하고 여전히 그것을 선택할 수 있습니다. –
좋은 설명. – abhishek