Click here to Skip to main content
15,892,575 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Silverlight development without Expression Blend Pin
Kevin McFarlane13-Nov-08 23:01
Kevin McFarlane13-Nov-08 23:01 
QuestionBind ObservableCollection to a Grid Pin
ezazazel12-Nov-08 11:02
ezazazel12-Nov-08 11:02 
AnswerRe: Bind ObservableCollection to a Grid Pin
Mark Salsbery12-Nov-08 12:22
Mark Salsbery12-Nov-08 12:22 
GeneralRe: Bind ObservableCollection to a Grid Pin
ezazazel12-Nov-08 20:02
ezazazel12-Nov-08 20:02 
GeneralRe: Bind ObservableCollection to a Grid Pin
Mark Salsbery12-Nov-08 20:37
Mark Salsbery12-Nov-08 20:37 
GeneralRe: Bind ObservableCollection to a Grid Pin
ezazazel13-Nov-08 2:13
ezazazel13-Nov-08 2:13 
GeneralRe: Bind ObservableCollection to a Grid Pin
Gideon Engelberth13-Nov-08 8:16
Gideon Engelberth13-Nov-08 8:16 
GeneralRe: Bind ObservableCollection to a Grid Pin
ezazazel13-Nov-08 9:55
ezazazel13-Nov-08 9:55 
Actually I'm doing this:
internal class ObsCollection<T> :ObservableCollection<T>
{
    private bool _suppressNotification = false;

    protected override void InsertItem(int index, T item)
    {
        base.InsertItem(index, item);
        if (item is INotifyPropertyChanged)
            (item as INotifyPropertyChanged).PropertyChanged += new PropertyChangedEventHandler(ObsCollection_PropertyChanged);
    }

    protected override void RemoveItem(int index)
    {
        if (this[index] is INotifyPropertyChanged)
            (this[index] as INotifyPropertyChanged).PropertyChanged -= new PropertyChangedEventHandler(ObsCollection_PropertyChanged);

        base.RemoveItem(index);
    }

    protected override void ClearItems()
    {
        //base.ClearItems();
        for (int i = 0; i < this.Count; i++)
        {
            RemoveItem(i);
        }
    }

    void ObsCollection_PropertyChanged(object sender, PropertyChangedEventArgs e)
    {
        OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
    }

    protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
    {
        if (!_suppressNotification)
            base.OnCollectionChanged(e);
    }

    public void AddRange(IEnumerable<T> list)
    {
        if (list == null)
            throw new ArgumentNullException("list");

        _suppressNotification = true;

        foreach (T item in list)
        {
            Add(item);
        }
        _suppressNotification = false;
        OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));

    }
}


and in the gridControl
void s_MElementCollection_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            command.SetElementsOnGrid(ref this.grid);
        }

internal void SetElementsOnGrid(ref Grid grid)
        {
            grid.Children.Clear();

            SetHeaders(ref grid);

            foreach (var item in s_Constructor.s_MElementCollection)
            {
                Grid.SetColumn(item, item.PositionDevice);
                Grid.SetRow(item, item.PositionAntenna);

                item.CommandParameter = item;
                item.Command = UICommands.uiCommand;

                if (item.IsEnabled)
                    if (item.IsError) item.Background = Brushes.OrangeRed; else item.Background = Brushes.Green;
                else item.Background = Brushes.DarkRed;



                grid.Children.Add(item);
            }
        }


Seems to work by now. What do you think about this aproach?
GeneralRe: Bind ObservableCollection to a Grid Pin
Gideon Engelberth13-Nov-08 12:47
Gideon Engelberth13-Nov-08 12:47 
GeneralRe: Bind ObservableCollection to a Grid [modified] Pin
Mark Salsbery14-Nov-08 12:40
Mark Salsbery14-Nov-08 12:40 
GeneralRe: Bind ObservableCollection to a Grid Pin
ezazazel15-Nov-08 1:54
ezazazel15-Nov-08 1:54 
GeneralRe: Bind ObservableCollection to a Grid Pin
Mark Salsbery15-Nov-08 6:46
Mark Salsbery15-Nov-08 6:46 
GeneralRe: Bind ObservableCollection to a Grid Pin
Mark Salsbery15-Nov-08 7:15
Mark Salsbery15-Nov-08 7:15 
QuestionComboBox's SelectedValue set to null when changing templates PinPopular
James J. Foster12-Nov-08 4:56
James J. Foster12-Nov-08 4:56 
QuestionAdobe Illustrator exporter to XAML Pin
DaveX8611-Nov-08 16:50
DaveX8611-Nov-08 16:50 
Questionhow can i read files from my silverlight 2 web folder Pin
ahmedhassan9611-Nov-08 12:41
ahmedhassan9611-Nov-08 12:41 
AnswerRe: how can i read files from my silverlight 2 web folder Pin
lneir12-Nov-08 18:42
lneir12-Nov-08 18:42 
QuestionWPF-Callable Folder Browser Source Code [modified] Pin
Mark Salsbery11-Nov-08 11:40
Mark Salsbery11-Nov-08 11:40 
AnswerRe: WPF-Callable Folder Browser Source Code Pin
Pete O'Hanlon11-Nov-08 11:44
mvePete O'Hanlon11-Nov-08 11:44 
GeneralRe: WPF-Callable Folder Browser Source Code Pin
Mark Salsbery11-Nov-08 11:55
Mark Salsbery11-Nov-08 11:55 
AnswerRe: WPF-Callable Folder Browser Source Code Pin
Jammer12-Nov-08 0:52
Jammer12-Nov-08 0:52 
GeneralRe: WPF-Callable Folder Browser Source Code Pin
Mark Salsbery12-Nov-08 8:41
Mark Salsbery12-Nov-08 8:41 
QuestionAdding events to objects in application.resources Pin
Rferj11-Nov-08 10:22
Rferj11-Nov-08 10:22 
AnswerRe: Adding events to objects in application.resources Pin
ColinM12311-Nov-08 11:19
ColinM12311-Nov-08 11:19 
GeneralUnable to upload file more than 35 kb using WCF Web service Pin
Vipul Mehta11-Nov-08 3:59
Vipul Mehta11-Nov-08 3:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.