내가 ObservableCollection에있는 경우 전, 후 프로젝트를 실행에 토글 버튼의 목록을 작성 taht를 목록 상자를 가지고 내가 ObservableCollection에있는 항목은 내가 (이 항목을 확인하려면 목록 상자에있는 경우 목록 상자에서 항목이 ObservableCollection에 비교 할 토글 버튼) 내가 그렇게 tryed했지만 난 후 프로젝트를 실행 보여 토글 버튼의 목록 렸기 때문에, 뒤에 코드에서 버튼을 전환 할 액세스 캔트ObservableCollection과 Toggle Button listBox를 비교합니까?
, 확인.
<ListBox x:Name="lbname" ItemsSource="{Binding source}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<ToggleButton x:Name="btnitem" Content="{Binding Name}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ListBox>
내 ObservableCollection에 : 한마디로
IQueryable<items> query = _context.items;
ocitems = new ObservableCollection<items>(query);
: 내가 목록 상자와 ObservableCollection에 항목을 비교할 수있는 방법 (버튼) 및 항목을 목록 상자에 존재하는 경우 전환을
여기 내 목록 상자 코드입니다 항목을 나타내는 버튼이 선택되어 있습니까?
이 명확한 희망.
------------------------------------------ 더 상세
, 내가 편집 버튼을 누르면,
<ListBox x:Name="lbChoices" ItemsSource="{Binding ocSelectedChoice}" DisplayMemberPath="ChoiceName" HorizontalAlignment="Left" Height="165" VerticalAlignment="Top" Width="186" Margin="567,50,0,0" BorderBrush="#FFC1C1C1" Background="#FFE3E3E3" SelectionMode="Extended">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="Height" Value="30"/>
<Setter Property="Background" Value="#FFc4d0df"/>
<Setter Property="BorderBrush" Value="#FFC1C1C1"/>
<Setter Property="BorderThickness" Value="0.8"/>
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
내가이 항목의 선택을 변경하려면
:
나는, ObservableCollection에 "ocSelectedChoice"에 의해 작성이 목록 상자 선택한 항목에 대한 선택을 보여이 목록 상자가 모든 가능한 선택에 대해 ObservableCollection에 의해 채워진리스트 박스가있는 윈도우를 보여줄 것입니다. 사진, 주요한 문제를보십시오. 'ch oices 1 선택 창에서 (녹색 하나) 확인 잠금 ':
<ItemsControl x:Name="icItemGroup" ItemsSource="{Binding PagedSource, ElementName=rdpChoices}" Margin="26,79,0,0" FontWeight="Bold" HorizontalAlignment="Left" Width="506" Height="210" VerticalAlignment="Top" >
<!-- ItemsPanelTemplate -->
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Columns="4" HorizontalAlignment="left" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<!-- ItemTemplate -->
<ItemsControl.ItemTemplate>
<DataTemplate>
<ToggleButton x:Name="tbtnChoices" HorizontalAlignment="Left" VerticalAlignment="Top" FontFamily="tahoma" FontSize="12" Height="45" Width="120" FontWeight="Normal" Margin="0,0,0,5" Background="#FFE8E8E8" BorderBrush="#FFC1C1C1" Foreground="#FF6A6A6A"
Content="{Binding ChoiceName}" TabIndex="{Binding ChoicesID}" Click="tbtnChoices_Click">
<ToggleButton.IsChecked>
<MultiBinding Converter="{StaticResource Choices}">
<Binding Path="ocChoice" RelativeSource="{RelativeSource AncestorType={x:Type Window}}"/>
</MultiBinding>
</ToggleButton.IsChecked>
</ToggleButton>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
변환기 :이 만들려고
public class ChoicesConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter,
System.Globalization.CultureInfo culture)
{
Choice _choice = values[0] as Choice;
ObservableCollection<Choice> ocChoices = values[1] as ObservableCollection<Choice>;
return ocChoices.Contains(_choice);
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter,
System.Globalization.CultureInfo culture)
{
return null;
}
}
,하지만 나를 위해 불분명 미안 여전히 뭔가주세요 내 프로젝트에서 중요하기 때문에이 문제를 해결하는 데 도움이됩니다.
나는 그것을 시도 할 것이다. –
제발 당신이 변환기를 만들 수 있도록 도와 주시겠습니까 –
변환기를 사용하여 답변을 업데이 트 .. 그것이 도움이 되었으면 좋겠다 – Nitin