주위를 둘러 보면서 라디오 버튼처럼 작동하는 GroupBox를 만들기를 바라고 있습니다. 헤더 섹션은 총알 역할을합니다. 나는 그것을보고하는 방법이다이 질문에라디오 버튼에 헤더를 추가하는 XAML
에서 일부 코드를했다. 그러나 나는 그것을 라디오 버튼으로 갖고 싶어. 그래서 나는 다음이 코드 (난 단지 지금은 주 2 WPF를 해왔을 마음)
<Style TargetType="{x:Type RadioButton}" >
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RadioButton}">
<BulletDecorator>
<BulletDecorator.Bullet>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Border x:Name="SelectedBorder"
Grid.Row="0"
Margin="4"
BorderBrush="Black"
BorderThickness="1"
Background="#25A0DA">
<Label x:Name="SelectedLabel" Foreground="Wheat">
<ContentPresenter Margin="4" />
</Label>
</Border>
<Border>
</Border>
</Grid>
</BulletDecorator.Bullet>
</BulletDecorator>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="true">
<Setter TargetName="SelectedBorder" Property="Background" Value="PaleGreen"/>
<Setter TargetName="SelectedLabel"
Property="Foreground"
Value="Black" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
내가 내 그리드의 두 번째 행에 레이블을 추가 할 수 있습니다 느낌이 듯했지만 나는 그것에 접근하는 방법을 모른다. 나는 Window.Resources 섹션에서 테스트 프로젝트에서 템플릿 내 윈도우 XAML (나는 내 주요 프로젝트에 리소스 사전에 이동 계획) 것을 가지고하는 것은 내가 다음과 같은 뭔가 희망이
<Grid>
<GroupBox Name="grpDoor" Margin ="8" Grid.Row="0" Grid.Column="0">
<GroupBox.Header>
WPF RadioButton Template
</GroupBox.Header>
<StackPanel Margin ="8">
<RadioButton FontSize="15" Content="Dhaka" Margin="4" IsChecked="False"/>
<RadioButton FontSize="15" Content="Munshiganj" Margin="4" IsChecked="True" />
<RadioButton FontSize="15" Content="Gazipur" Margin="4" IsChecked="False" />
</StackPanel>
</GroupBox>
</Grid>
입니다 당신의 설명을 바탕으로
<Grid>
<GroupBox Name="grpDoor" Margin ="8" Grid.Row="0" Grid.Column="0">
<GroupBox.Header>
WPF RadioButton Template
</GroupBox.Header>
<StackPanel Margin ="8">
<RadioButton FontSize="15"
Content="Dhaka"
Margin="4"
IsChecked="False">
<RadioButton.Description>
This is a description that would show under my Header
</RadioButton.Description>
</RadioButton>
<RadioButton FontSize="15"
Content="Munshiganj"
Margin="4"
IsChecked="True">
<RadioButton.Description>
This is a description that would show under my Header
</RadioButton.Description>
</RadioButton>
<RadioButton FontSize="15"
Content="Gazipur"
Margin="4"
IsChecked="False">
<RadioButton.Description>
This is a description that would show under my Header
</RadioButton.Description>
</RadioButton>
</StackPanel>
</GroupBox>
</Grid>
설명해주세요. RadioButton처럼 동작하는 GroupBox가 필요합니까? 그렇다면 RadioButton을 사용하고 GroupBox 세트처럼 보이도록 스타일을 지정하는 것이 더 쉽습니다. – Trevor
@ Trevor yeah 내 계획입니다. –