wpf - Converter stops filter working -


I'm trying to display the file name in a listbox, taken from a special directory. They are stored in an ObservableCollection of FileInfo Object:

  Public supervision & lt; FileInfo & gt; Project Files {Get (empty (selected folder == empty); DirectoryInfo D = New Directory Info (SelectedFolder); if (! D.Extists) returns empty; New Observe Collection & lt; FileInfo & gt; (d.EnumerateFiles ( Return "* .xsi")}}}  

When a text is entered or a text box has changed in "FilesFilterBy" I applied a filter on the listbox, called Is:

  Private Zero FilterFiles_TextChanged (Object Sender, TextChangedEventArgs e) {ICollectionView View = Archive Source.GetDefaultView (ProjectFiles); see.filters = new new & amp; object> (IsTextInFilename);} public bool isTextInFilename (object item) {string file name = path.GetFileNameWithoutExtension (as fileInfo) .Name item Returns (filename. ToLower (). Includes (File Byte Text. Taylor ());}  

At the same time, I can only name files, paths or I want to display without the extension. To this end I have implemented a converter:

  abstract Vjnik class RemoveExtensionConverter: IValueConverter {public object Convert (object value, Type TargetType, object parameters, CultureInfo culture) {return Path.GetFileNameWithoutExtension (value as string); } Public Object Convertback (type object type, type type, object parameter, culture input culture) {new naturally exposed (return); }}  

Here is how the listbox is executed in XAML:

  & lt; Window.Resources & gt; & Lt; Ctr: RemoveExtensionConverter x: Key = "JustFileName" /> & Lt; /Window.Resources> & Lt; ListBox ItemsSource = "{Binding ProjectFiles}" & gt; & Lt; ListBox.ItemTemplate & gt; & Lt; DataTemplate & gt; & Lt; Text block text = "{binding full name, converter = {static resource JustFileName}}" /> & Lt; / DataTemplate & gt; & Lt; /ListBox.ItemTemplate> & Lt; / ListBox & gt;  

Currently the converter works - only the filenames are listed, but the filter has no effect. When I enter text in the FileFilterBy textbox, the text-changed event is removed, but the listbox remains the same. Also, the converter is not said at that point.

Am I doing wrong?

After the

Each of the ProjectFiles gives a new collection of your FilterFiles_TextChanged handler, calling the project file to create a new archive , Is setting the filter on that new collection, and then throwing it is not affected by the collection that is bound to the list box. You must change the project file to have the same collection object. Something like this might be:

Private Observe Collection & lt; FileInfo & gt; _projectFiles; Public observable selection & lt; FileInfo & gt; Project Files {Receive (if (_projectFiles == zero) {if (empty folder selected == empty); DirectoryInfo D = New Directory Info (SelectedFolder); if (! D.Extists) returns empty; _projectFiles = new observable selection & lt ; FileInfo & gt; (d.EnumerateFiles ("* .xsi"));} Return _projectFiles;}}

The converter filter should not be affected at all.

< / Div>

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -