터치 장치에서 WPF 개발을 시작합니다. .NET과 WPF가 놀라운 기술 인 것 같지만 다소 길을 잃었습니다.WPF : 색상을 통합하는 Style ListBoxItem
일반 컨트롤을 개발 중입니다. 그리드, 일부 버튼 및 SurfaceListBox가 포함 된 UserControl을 정의했습니다. 실제 C# 코드에서는 이벤트를 처리하고 listItems-Attribute를 조작하여 목록 상자에 새 요소를 추가합니다. 지금까지 잘 작동합니다.
이제 목록 항목의 스타일을 변경하고 싶습니다. 선택하지 않으면 배경을 투명하게 만들고 싶은 경우 투명하게 만들고 싶습니다. 불행히도 다음 코드는 작동하지 않습니다. 그냥 목록 항목 의 배경색을 흰색으로 설정하지만 전체 항목은 설정하지 않습니다.
업데이트 : 이제 작동합니다!
<UserControl x:Class="SGEditor.MyControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
xmlns:my="http://schemas.microsoft.com/surface/2008" UseLayoutRounding="True">
<UserControl.Resources>
<Style TargetType="{x:Type ListBoxItem}" x:Key="ContainerStyle">
<Setter Property="Background" Value="Transparent" />
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="White" />
</Trigger>
</Style.Triggers>
</Style>
</UserControl.Resources>
<Grid>
<my:SurfaceListBox Width="300" Height="300" />
</Grid>
</UserControl>
고마워요!
한스
안녕하세요, 감사합니다. 내 질문 업데이트;) – HansSchild
좋아, 알았어. 고마워 친구! – HansSchild