Click here to Skip to main content
15,911,896 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Silverlight slider - binding lost when value is out-of-range Pin
Wjousts30-Sep-11 10:08
Wjousts30-Sep-11 10:08 
GeneralRe: Silverlight slider - binding lost when value is out-of-range Pin
Wjousts30-Sep-11 9:55
Wjousts30-Sep-11 9:55 
QuestionWPF combobox selecteditem issue Pin
PretzelB29-Sep-11 5:34
PretzelB29-Sep-11 5:34 
AnswerRe: WPF combobox selecteditem issue Pin
Ian Shlasko29-Sep-11 5:57
Ian Shlasko29-Sep-11 5:57 
GeneralRe: WPF combobox selecteditem issue Pin
PretzelB29-Sep-11 6:19
PretzelB29-Sep-11 6:19 
GeneralRe: WPF combobox selecteditem issue Pin
Ian Shlasko29-Sep-11 8:43
Ian Shlasko29-Sep-11 8:43 
GeneralRe: WPF combobox selecteditem issue Pin
PretzelB29-Sep-11 9:31
PretzelB29-Sep-11 9:31 
GeneralRe: WPF combobox selecteditem issue Pin
Ian Shlasko29-Sep-11 10:32
Ian Shlasko29-Sep-11 10:32 
Well the trick is that you're not returning an item from the list of categories... You're returning an entirely different item with the same properties, when you do this:
VB
Public Function GetMyCategory(ByVal id As Int32) As myCategory
    Dim results = From c In _mycateorylist
            Where c.CategoryID = id
            Select c
    Dim rs As IEnumerable(Of myCategory) = From x In results.AsEnumerable
                  Select New myCategory With
                         {
                             .CategoryID = x.CategoryID,
                             .CategoryName = x.CategoryName
                         }
    Return rs.FirstOrDefault
End Function

If you just return results.FirstOrDefault, it'll give you the first result from the actual list. You're also doing the same thing with GetMyCategories(), by calling it once in the data model's constructor, and again in the view model's constructor, yielding two different collections with identical contents. The idea is to have one collection in the data model, give the view model a reference to that collection, and let the GUI bind to the view model's reference, so they all point to the same data.
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels)

AnswerRe: WPF combobox selecteditem issue Pin
Simon Bang Terkildsen29-Sep-11 8:07
Simon Bang Terkildsen29-Sep-11 8:07 
GeneralRe: WPF combobox selecteditem issue Pin
PretzelB29-Sep-11 9:27
PretzelB29-Sep-11 9:27 
QuestionHow to use WPF to implement multi-pen drawing? Pin
rehuo28-Sep-11 21:58
rehuo28-Sep-11 21:58 
AnswerRe: How to use WPF to implement multi-pen drawing? Pin
rehuo5-Oct-11 20:02
rehuo5-Oct-11 20:02 
QuestionHow to get WM_Gesture messages in WPF4.0 touch aware application? Pin
manil kumar28-Sep-11 21:15
manil kumar28-Sep-11 21:15 
QuestionListBox Binding Pin
Samir.Sh28-Sep-11 20:46
Samir.Sh28-Sep-11 20:46 
GeneralRe: ListBox Binding Pin
Samir.Sh29-Sep-11 20:16
Samir.Sh29-Sep-11 20:16 
QuestionObsolete Examples Pin
michaelbarb28-Sep-11 8:53
michaelbarb28-Sep-11 8:53 
AnswerRe: Obsolete Examples Pin
AnnieMacD28-Sep-11 10:05
AnnieMacD28-Sep-11 10:05 
GeneralRe: Obsolete Examples Pin
michaelbarb28-Sep-11 10:21
michaelbarb28-Sep-11 10:21 
GeneralRe: Obsolete Examples Pin
SledgeHammer0128-Sep-11 10:46
SledgeHammer0128-Sep-11 10:46 
GeneralRe: Obsolete Examples Pin
michaelbarb29-Sep-11 8:13
michaelbarb29-Sep-11 8:13 
GeneralRe: Obsolete Examples Pin
SledgeHammer0129-Sep-11 8:40
SledgeHammer0129-Sep-11 8:40 
GeneralRe: Obsolete Examples Pin
michaelbarb29-Sep-11 8:50
michaelbarb29-Sep-11 8:50 
GeneralRe: Obsolete Examples Pin
SledgeHammer0129-Sep-11 10:08
SledgeHammer0129-Sep-11 10:08 
GeneralRe: Obsolete Examples Pin
michaelbarb29-Sep-11 10:48
michaelbarb29-Sep-11 10:48 
GeneralRe: Obsolete Examples Pin
SledgeHammer0129-Sep-11 12:20
SledgeHammer0129-Sep-11 12:20 

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.