I want to output the data from the array to the checkbox, but I can’t bring up to a certain type to get

XAML

<ItemsControl ItemsSource="{Binding MyProperty}" Margin="0" Grid.Column="1" Grid.RowSpan="1" > <ItemsControl.ItemTemplate> <DataTemplate> <dxe:CheckEdit Content="{Binding FilePath}" Padding="2.5" Margin="3" IsChecked="{Binding IsChecked}"/> </DataTemplate> </ItemsControl.ItemTemplate> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <WrapPanel Orientation="Vertical" /> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> </ItemsControl> 

C #

  public List<DataText> list; private ObservableCollection<MyCheckBox> Items = new ObservableCollection<MyCheckBox>(); public ICollectionView ItemsView { get; set; } public TextViewModel() { Items.Add(new MyCheckBox { FilePath = "Debug.txt", IsChecked = false }); Items.Add(new MyCheckBox { FilePath = "Info", IsChecked = false }); Items.Add(new MyCheckBox { FilePath = "Error", IsChecked = false }); Items.Add(new MyCheckBox { FilePath = "Fatal", IsChecked = true }); Items.Add(new MyCheckBox { FilePath = "Fine", IsChecked = true }); Items.Add(new MyCheckBox { FilePath = "Finer", IsChecked = true }); Items.Add(new MyCheckBox { FilePath = "Finest", IsChecked = true }); Items.Add(new MyCheckBox { FilePath = "Warn", IsChecked = true }); ItemsView = CollectionViewSource.GetDefaultView(Items); list = new List<DataText>(); } IEnumerable<DataText> blabal; public IEnumerable<DataText> MyProperty { get { return list.Where(x => ItemsView.Contains(x.TypeFiles)); } set { blabal= value; OnPropertyChange("MyProperty"); } } #region Command private RelayCommand _openCommand; public ICommand OpenCommand { get { return _openCommand = new RelayCommand(param => OpenDial(), param => CanOpen); } } private void OpenDial() { FolderBrowserDialog fb = new FolderBrowserDialog(); DialogResult result = fb.ShowDialog(); var dir = new DirectoryInfo(fb.SelectedPath); // папка с файлами var files = new List<string>(); // список для имен файлов var temp = dir.GetFiles("*.txt.*"); foreach (FileInfo file in dir.GetFiles("*.txt.*")) // извлекаем все файлы и кидаем их в список { // files.Add(Path.GetFileNameWithoutExtension(file.FullName));// получаем полный путь к файлу и потом вычищаем ненужное, оставляем только имя файла. files.Add(Path.GetFileName(file.FullName)); } list = ReadTextFile.LoadDateListFromFile(files); var newList = list.Where(x => ItemsView.Contains(x.TypeFiles)); MyProperty = newList; DataT = list; } 

How do I link the data? Nothing is displayed.

This is how a filter should look like

enter image description here

  • Please give an example of the data, and an example of how the result should look like (which line should be displayed). - VladD
  • All itemsView should be shown, if it is in the list, that is, if you need to debug.txt, info.txt, error.txt, then checkEdit debug, info, error should be set so that you can filter them later - momo
  • Can you give a specific example? - VladD
  • You have in xaml ItemsSource = "{Binding MyProperty}", which is a collection of DataText, but then you tied up on the Holy Island MyCheckBox. - Joffrey
  • one
    For the filter, you need to bind a collection to the ItemsView, which has filtering tools msdn.microsoft.com/en-us/library/… - Joffrey

0