Click here to Skip to main content
11,484,402 members (65,803 online)

Silverlight / WPF

 
GeneralRe: round slider Pin
robotz8-Oct-09 11:32
memberrobotz8-Oct-09 11:32 
QuestionMedia element fullscreen Pin
Nekkantidivya7-Oct-09 20:29
memberNekkantidivya7-Oct-09 20:29 
AnswerRe: Media element fullscreen Pin
Nigel Ferrissey8-Oct-09 17:03
memberNigel Ferrissey8-Oct-09 17:03 
QuestionCalling SSL WCF Service from Silverlight Pin
Soulforged7-Oct-09 16:47
memberSoulforged7-Oct-09 16:47 
AnswerRe: Calling SSL WCF Service from Silverlight Pin
Nigel Ferrissey7-Oct-09 20:19
memberNigel Ferrissey7-Oct-09 20:19 
GeneralRe: Calling SSL WCF Service from Silverlight Pin
Soulforged8-Oct-09 14:41
memberSoulforged8-Oct-09 14:41 
AnswerRe: Calling SSL WCF Service from Silverlight Pin
Mark Salsbery8-Oct-09 11:19
mvpMark Salsbery8-Oct-09 11:19 
QuestionSelector (ListBox, ComboBox) default selected item woes when bound to ObservableCollection Pin
Jeremy Likness7-Oct-09 11:32
memberJeremy Likness7-Oct-09 11:32 
OK, here is the scenario. Take a selector (any type of list item that you can select values) and bind it to an observable collection. Let's say that collection is populated from a service call.

The issue is that you bind, the collection is empty, so there is no selected index. You cannot plug into the Loaded event on the box because if you try to set selectedindex = 0, and the collection hasn't loaded yet, you're out of luck.

In the code behind I can wire into the collectionchanged and then set selectedindex = 0 but that seems a little contrived.

I have a full solution using attached properties but it seems overly complicated for the behavior (I want to always default to the first item in a collection when the collection becomes available).

Anyone have a similiar scenario and thoughts about a solution?

One thing I looked at was having the view model raise a "collection loaded" event, but then again the view will have to hook into that in the code behind.

My attached properties solution basically creates a list of weak references between the selectors and the collections, then hooks into the collection changed event. When it fires, it finds the selector it is linked to and then sets the selected index. It works like a charm but I want to make sure I'm not overcomplicating it when there may be some setting that says, "Default to the first item" when a collection gets filled.

Thanks,

Jeremy


AnswerRe: Selector (ListBox, ComboBox) default selected item woes when bound to ObservableCollection Pin
Nigel Ferrissey8-Oct-09 13:08
memberNigel Ferrissey8-Oct-09 13:08 
QuestionCan DataGrid Swap Row and Column? Pin
Frank W. Wu7-Oct-09 11:13
memberFrank W. Wu7-Oct-09 11:13 
AnswerRe: Can DataGrid Swap Row and Column? Pin
Nigel Ferrissey9-Oct-09 13:22
memberNigel Ferrissey9-Oct-09 13:22 
Questioncombobox usage Pin
VCsamir6-Oct-09 22:22
memberVCsamir6-Oct-09 22:22 
QuestionRe: combobox usage Pin
Mark Salsbery7-Oct-09 8:22
mvpMark Salsbery7-Oct-09 8:22 
Questioncan we use wpf controls in window's application . Pin
anuj17846-Oct-09 20:35
memberanuj17846-Oct-09 20:35 
AnswerRe: can we use wpf controls in window's application . Pin
Pete O'Hanlon6-Oct-09 22:47
mvpPete O'Hanlon6-Oct-09 22:47 
GeneralRe: can we use wpf controls in window's application . Pin
anuj17846-Oct-09 22:54
memberanuj17846-Oct-09 22:54 
GeneralRe: can we use wpf controls in window's application . Pin
Christian Graus6-Oct-09 23:11
mvpChristian Graus6-Oct-09 23:11 
GeneralRe: can we use wpf controls in window's application . Pin
Pete O'Hanlon6-Oct-09 23:55
mvpPete O'Hanlon6-Oct-09 23:55 
GeneralRe: can we use wpf controls in window's application . Pin
anuj17847-Oct-09 0:11
memberanuj17847-Oct-09 0:11 
QuestionCustom scrolling in WPF control Pin
grvdarji6-Oct-09 12:51
membergrvdarji6-Oct-09 12:51 
QuestionRe: Custom scrolling in WPF control Pin
Mark Salsbery7-Oct-09 8:41
mvpMark Salsbery7-Oct-09 8:41 
AnswerRe: Custom scrolling in WPF control Pin
grvdarji8-Oct-09 6:10
membergrvdarji8-Oct-09 6:10 
GeneralRe: Custom scrolling in WPF control Pin
Mark Salsbery9-Oct-09 7:26
mvpMark Salsbery9-Oct-09 7:26 
GeneralRe: Custom scrolling in WPF control Pin
grvdarji9-Oct-09 11:45
membergrvdarji9-Oct-09 11:45 
QuestionUsing Aero theme in WPF Pin
Etienne_1236-Oct-09 11:59
memberEtienne_1236-Oct-09 11:59 

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

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


Advertise | Privacy | Mobile
Web04 | 2.8.150520.1 | Last Updated 22 May 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid