Click here to Skip to main content
15,906,319 members
Home / Discussions / C#
   

C#

 
AnswerRe: For Developinf Login Application for windows Pin
Pete O'Hanlon11-Dec-12 20:54
mvePete O'Hanlon11-Dec-12 20:54 
AnswerRe: For Developinf Login Application for windows Pin
Richard Deeming12-Dec-12 1:48
mveRichard Deeming12-Dec-12 1:48 
Questionstoring image in isolated storage Pin
singh123456711-Dec-12 18:39
singh123456711-Dec-12 18:39 
QuestionHow to print an SSRS Report in PDF Format from my asp.net page Pin
Vinay Meka11-Dec-12 18:04
Vinay Meka11-Dec-12 18:04 
AnswerRe: How to print an SSRS Report in PDF Format from my asp.net page Pin
Richard Deeming12-Dec-12 1:42
mveRichard Deeming12-Dec-12 1:42 
Questionadd labels to an image at different zoom levels Pin
vr99999999911-Dec-12 18:03
vr99999999911-Dec-12 18:03 
AnswerRe: add labels to an image at different zoom levels Pin
Pete O'Hanlon11-Dec-12 20:17
mvePete O'Hanlon11-Dec-12 20:17 
GeneralRe: add labels to an image at different zoom levels Pin
vr99999999911-Dec-12 20:28
vr99999999911-Dec-12 20:28 
GeneralRe: add labels to an image at different zoom levels Pin
Pete O'Hanlon11-Dec-12 20:34
mvePete O'Hanlon11-Dec-12 20:34 
GeneralRe: add labels to an image at different zoom levels Pin
vr99999999911-Dec-12 20:41
vr99999999911-Dec-12 20:41 
Questionhello friend :) Pin
youshy11-Dec-12 7:38
youshy11-Dec-12 7:38 
AnswerRe: hello friend :) Pin
fjdiewornncalwe11-Dec-12 8:03
professionalfjdiewornncalwe11-Dec-12 8:03 
GeneralRe: hello friend :) Pin
youshy11-Dec-12 8:48
youshy11-Dec-12 8:48 
SuggestionRe: hello friend :) Pin
youshy11-Dec-12 9:07
youshy11-Dec-12 9:07 
AnswerRe: hello friend :) Pin
fjdiewornncalwe11-Dec-12 10:34
professionalfjdiewornncalwe11-Dec-12 10:34 
AnswerRe: hello friend :) Pin
Pete O'Hanlon11-Dec-12 8:22
mvePete O'Hanlon11-Dec-12 8:22 
GeneralRe: hello friend :) Pin
youshy11-Dec-12 9:12
youshy11-Dec-12 9:12 
GeneralMessage Removed Pin
12-Dec-12 2:50
professionalN_tro_P12-Dec-12 2:50 
GeneralRe: hello friend :) Pin
Pete O'Hanlon12-Dec-12 2:53
mvePete O'Hanlon12-Dec-12 2:53 
QuestionBest way to do this? Pin
SledgeHammer0111-Dec-12 4:55
SledgeHammer0111-Dec-12 4:55 
AnswerRe: Best way to do this? Pin
Gerry Schmitz11-Dec-12 12:28
mveGerry Schmitz11-Dec-12 12:28 
GeneralRe: Best way to do this? Pin
SledgeHammer0111-Dec-12 13:21
SledgeHammer0111-Dec-12 13:21 
I was trying to avoid having 2 collections and "sync'ing" them up. I'm probably not going to have that many items, but purposely storing multiple copies of the same object is not something I want to do. In regards to step #2 and #3, I'm going to be using data binding, so it all really needs to be the same instance of all the objects. I came up with something that sort of works, but I'm not happy with it:

C#
public class HybridCollection : ObservableDictionary<ObjType, ObservableCollection<Obj>>
{
    public HybridCollection()
        : base()
    {
    }

    public void Add(Obj o)
    {
        ObservableCollection<Obj> lst = null;

        if (!this.TryGetValue(o.Type, out lst))
        {
            lst = new ObservableCollection<Obj>();
            this[o.Type] = lst;
        }

        lst.Add(o);

        cv.Refresh();
    }

    public IEnumerable<Obj> FlatView
    {
        get
        {
            foreach (ObservableCollection<Obj> lst in Values)
            {
                foreach (Obj obj in lst)
                    yield return obj;
            }
        }
    }

    private CollectionView cv = null;

    public CollectionView FlatView2
    {
        get
        {
            if (cv == null)
                cv = new CollectionView(FlatView);

            return cv;
        }
    }
}


So what happens is, the data is stored hierachially so the treeview can bind to it with the HierachialDataTemplates. FlatView2 just returns an IEnumerable where it enums through all the branches and yields the original objects back.

Unfortunately, in the Add() method (and of course the delete, etc methods), there is a cv.Refresh() call to refresh the flat view since the IEnumerable isn't going to be able to propogate change notifications. So the treeview is going to use optimized data binding where it adds / removes only the affected items, but the listview will be reloading the entire list. Ugh.

I guess I will have to return an ObservableCollection instead of the IEnumerable... was kind of hoping to prevent that.
GeneralRe: Best way to do this? Pin
Gerry Schmitz11-Dec-12 14:05
mveGerry Schmitz11-Dec-12 14:05 
GeneralRe: Best way to do this? Pin
SledgeHammer0111-Dec-12 14:25
SledgeHammer0111-Dec-12 14:25 
Questiondevelop code project functionality(view forums/questions) in codeproject like steps View Pin
Firoz(Pappu)11-Dec-12 3:40
Firoz(Pappu)11-Dec-12 3:40 

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.