<ListBox ItemsSource="{Binding XyzList}" BorderThickness="0" Background="Transparent">
<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}">
<Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<ContentPresenter/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Image Visibility="{Binding Stop}"
ToolTip="{Binding Stopp}"
HorizontalAlignment="Left"
Opacity="1" Width="11" Height="11"
Source=stop.png"/>
<RadioButton Content="{Binding Period}"
IsEnabled="{Binding Ok}"
IsChecked="{Binding IsSelected}"
Margin="20,0,0,0" HorizontalAlignment="Left"
Command="Views:ValjLeveransArende.PrCommand"/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
ラジオボタンを初めて選択すると、選択されず、正しいデータが取得されますが、選択されません。リストボックスのwpfラジオボタンが初めてチェックされない
もう一度試すと、選択されます。
詳細情報:
public class XyzList: WorkViewModelBase
{
private bool _isSelected;
public bool IsSelected
{
get { return _isSelected; }
set
{
_isSelected = value;
OnPropertyChanged(nameof(IsSelected));
}
}
}
そして私は、私はこの
list.Add(new XyzList()
{
IsSelected = false
});
プログラム開始時の 'IsSelected'の値は?拘束力のある問題のようです... –
コード内でfalseに設定されています –
xamltoを変更しようとしましたか?チェックボックスIsChecked = "{バインディングIsSelected、UpdateSourceTrigger = PropertyChanged}"? – DRapp