Click here to Skip to main content
15,885,919 members
Home / Discussions / WPF
   

WPF

 
QuestionFormat datetime value in XMAL Pin
Garrisoft9-Mar-10 1:03
Garrisoft9-Mar-10 1:03 
AnswerRe: Format datetime value in XMAL Pin
Abhinav S14-Mar-10 21:11
Abhinav S14-Mar-10 21:11 
QuestionHow to avoid 'System.StackOverflowException' when saving a canvas in a xaml Pin
Bhagya Thambugala8-Mar-10 6:22
Bhagya Thambugala8-Mar-10 6:22 
QuestionDatabinding to a single element from RIA [modified] Pin
Pankaj Nikam8-Mar-10 5:14
professionalPankaj Nikam8-Mar-10 5:14 
QuestionListView issues Pin
#realJSOP6-Mar-10 3:37
mve#realJSOP6-Mar-10 3:37 
AnswerRe: ListView issues Pin
Eslam Afifi6-Mar-10 8:19
Eslam Afifi6-Mar-10 8:19 
GeneralRe: ListView issues Pin
#realJSOP6-Mar-10 9:35
mve#realJSOP6-Mar-10 9:35 
GeneralRe: ListView issues Pin
Eslam Afifi6-Mar-10 10:51
Eslam Afifi6-Mar-10 10:51 
John Simmons / outlaw programmer wrote:
the list cannot inherit from IBindingList or ObservableCollection


I didn't say you should inherit from ObservableCollection. I said,

Eslam Afifi wrote:
bind to an ObservableCollection and add and remove items to that ObservableCollection manually


Maybe I wasn't clear enough. In this case, I'm sorry. But I meant to bind to an ObservableCollection not the List in question. Something like that,

List<A> _aModels = new List<A>(); // the list not to be touched
ObservableCollection<AViewModel> _aViewModels = new ObservableCollection<AViewModel>();

// and adding to to the ObservableCollection when adding to the List to keep them in sync. the same for removing.
var aModel = new A { X = _random.Next(), Y = _random.Next(), Z = _random.Next() };
_aModels.Add(aModel);
_aViewModels.Add(new AViewModel(aModel));

// bind the ObservableCollection to the ListView's ItemsSource


As for setting which property to use of columns. It works even when adding items manually to the ListView's Items property and not using ItemsSource.
ItemsSource
<ListView.View>
    <GridView>
        <GridView.Columns>
            <!-- the ViewModel exposes the X, Y and Z properties -->
            <GridViewColumn Header="X" DisplayMemberBinding="{Binding X}" Width="100" />
            <GridViewColumn Header="Y" DisplayMemberBinding="{Binding Y}" Width="100" />
            <GridViewColumn Header="Z" DisplayMemberBinding="{Binding Z}" Width="100" />
        </GridView.Columns>
    </GridView>
</ListView.View>


I replied to your question based on what I understood from it. You said you can't inherit from ObservableCollection and I don't think using a separate object of ObservableCollection would break the compatibility with the already existing windows forms code. If you mean you can't even use a separate instance of ObservableCollection because it breaks existing code, why would it break the code?
Eslam Afifi

GeneralRe: ListView issues Pin
Pete O'Hanlon6-Mar-10 11:14
mvePete O'Hanlon6-Mar-10 11:14 
GeneralRe: ListView issues Pin
Eslam Afifi6-Mar-10 12:27
Eslam Afifi6-Mar-10 12:27 
GeneralRe: ListView issues Pin
Pete O'Hanlon6-Mar-10 12:34
mvePete O'Hanlon6-Mar-10 12:34 
GeneralRe: ListView issues Pin
Eslam Afifi6-Mar-10 13:02
Eslam Afifi6-Mar-10 13:02 
GeneralRe: ListView issues Pin
Pete O'Hanlon6-Mar-10 9:41
mvePete O'Hanlon6-Mar-10 9:41 
AnswerRe: ListView issues Pin
Pete O'Hanlon6-Mar-10 10:22
mvePete O'Hanlon6-Mar-10 10:22 
QuestionDisplay System.Windows.Forms.Form as child of Wpf Window Pin
abhinish6-Mar-10 1:01
abhinish6-Mar-10 1:01 
AnswerRe: Display System.Windows.Forms.Form as child of Wpf Window Pin
#realJSOP6-Mar-10 2:17
mve#realJSOP6-Mar-10 2:17 
GeneralRe: Display System.Windows.Forms.Form as child of Wpf Window Pin
abhinish6-Mar-10 5:00
abhinish6-Mar-10 5:00 
GeneralRe: Display System.Windows.Forms.Form as child of Wpf Window Pin
#realJSOP6-Mar-10 5:29
mve#realJSOP6-Mar-10 5:29 
GeneralRe: Display System.Windows.Forms.Form as child of Wpf Window Pin
Valentin Billotte31-May-10 4:51
Valentin Billotte31-May-10 4:51 
QuestionBackgroundWorker and comboBox.Items.Add(f) Pin
HahnTech5-Mar-10 15:35
HahnTech5-Mar-10 15:35 
AnswerRe: BackgroundWorker and comboBox.Items.Add(f) Pin
#realJSOP6-Mar-10 2:18
mve#realJSOP6-Mar-10 2:18 
GeneralRe: BackgroundWorker and comboBox.Items.Add(f) Pin
HahnTech8-Mar-10 12:31
HahnTech8-Mar-10 12:31 
QuestionMessage Removed Pin
5-Mar-10 3:38
professionalN_tro_P5-Mar-10 3:38 
AnswerRe: ResourceDictionaries Pin
Pete O'Hanlon5-Mar-10 4:34
mvePete O'Hanlon5-Mar-10 4:34 
GeneralMessage Removed Pin
5-Mar-10 8:33
professionalN_tro_P5-Mar-10 8:33 

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.