Display Change (UI) / Element Order Observed Collection

EDIT No. 2:

    public void ReverseOrderRegBtns()
    {
        ICollectionView view = CollectionViewSource.GetDefaultView(GlobalObservableCol.regBtns);
        view.SortDescriptions.Add(new SortDescription("ReverseOrder", ListSortDirection.Ascending));
        view.Refresh();
    }

Not sure how to approach ICollectionView, it also interrupts timers that execute some logic. For some reason, it interrupts my time, which starts counting down when a button is created.

My application has several timers, so the buttons that are created receive updates with possible new content every x seconds.

EDIT:

Data binding is as follows:

<ListBox x:Name="lbRegistration" ItemsSource="{Binding regBtnsReverse, ElementName=Window}" Background="{x:Null}" 

Old:    public ObservableCollection RegBtns {get {if (GlobalObservableCol.regBtns == null) {return new ObservableCollection (); } return GlobalObservableCol.regBtns; }}

( ), ObserableCol

public IEnumerable<RegistrationButton> RegBtns
        {
            get
            {
                return GlobalObservableCol.regBtnsReverse;
            }
        }

IEnumerable , ObservableCollection.

, IENumerable. NumbersReverse  , MainWindow.xls?


ObservableCollection, WPF.

(listbox). , 1, 2, 3,...

, , .

, 3, 2, 1. , Observable .

, ( ).

?

, PeterP

+3
3
<ListBox ItemsSource="{Binding Foo}"/>

private ObservableCollection<RegButtton> RegBtns = new...;

public ICollectionView Foo { get; set; }

Foo = CollectionViewSource.GetDefaultView(RegBtns);
Foo.SortDescriptions.Add(new SortDescription("SomePropertyName", ListSortDirection.Ascending));
Foo.Refresh();
+2

- myCollection.Add( someButton ).

myCollection.Insert( 0, myButton ), .

+2

, . - :

public ObservableCollection<int> Numbers { get; private set; }
public IEnumerable<int> NumbersReverse
{
    get
    {
        return Numbers.Reverse();
    }

}

NumbersReverse :

<ListBox Name="listBox1" ItemsSource="{Binding NumbersReverse}"/>

, . , ...

: - , , stijn, .

+1

All Articles