Click here to Skip to main content
16,020,622 members
Home / Discussions / WPF
   

WPF

 
QuestionMedia element fullscreen Pin
Nekkantidivya7-Oct-09 19:29
Nekkantidivya7-Oct-09 19:29 
AnswerRe: Media element fullscreen Pin
Nigel Ferrissey8-Oct-09 16:03
Nigel Ferrissey8-Oct-09 16:03 
QuestionCalling SSL WCF Service from Silverlight Pin
Soulforged7-Oct-09 15:47
Soulforged7-Oct-09 15:47 
AnswerRe: Calling SSL WCF Service from Silverlight Pin
Nigel Ferrissey7-Oct-09 19:19
Nigel Ferrissey7-Oct-09 19:19 
GeneralRe: Calling SSL WCF Service from Silverlight Pin
Soulforged8-Oct-09 13:41
Soulforged8-Oct-09 13:41 
AnswerRe: Calling SSL WCF Service from Silverlight Pin
Mark Salsbery8-Oct-09 10:19
Mark Salsbery8-Oct-09 10:19 
QuestionSelector (ListBox, ComboBox) default selected item woes when bound to ObservableCollection Pin
Jeremy Likness7-Oct-09 10:32
professionalJeremy Likness7-Oct-09 10:32 
AnswerRe: Selector (ListBox, ComboBox) default selected item woes when bound to ObservableCollection Pin
Nigel Ferrissey8-Oct-09 12:08
Nigel Ferrissey8-Oct-09 12:08 
Hi Jeremy,

One way could be to have a property in the ViewModel like this:

private int _selectedIndex = -1;
public int SelectedIndex
{
    get { return _selectedIndex; }
    set
    {
        if (value != _selectedIndex)
        {
            _selectedIndex = value;
            NotifyPropertyChanged("SelectedIndex");
        }
     }
}


It's set to -1 initially so the XAML doesn't throw an error when there's no collection to bind to.

Bind it to the list box:

<ListBox ItemsSource="{Binding Employees}" SelectedIndex="{Binding SelectedIndex}" />


Then, in the completed event (when the service returns from the asynchronous call with the data) you can set it to whatever you want.

void svcClient_GetDataCompleted(object sender, EmployeeSvc.GetDataCompletedEventArgs e)
{
    Employees = e.Result;
    SelectedIndex = 1;
}


Not particularly elegant, but it seems to work.

Cheers.
QuestionCan DataGrid Swap Row and Column? Pin
Frank W. Wu7-Oct-09 10:13
Frank W. Wu7-Oct-09 10:13 
AnswerRe: Can DataGrid Swap Row and Column? Pin
Nigel Ferrissey9-Oct-09 12:22
Nigel Ferrissey9-Oct-09 12:22 
Questioncombobox usage Pin
VCsamir6-Oct-09 21:22
VCsamir6-Oct-09 21:22 
QuestionRe: combobox usage Pin
Mark Salsbery7-Oct-09 7:22
Mark Salsbery7-Oct-09 7:22 
Questioncan we use wpf controls in window's application . Pin
Anuj Banka6-Oct-09 19:35
Anuj Banka6-Oct-09 19:35 
AnswerRe: can we use wpf controls in window's application . Pin
Pete O'Hanlon6-Oct-09 21:47
mvePete O'Hanlon6-Oct-09 21:47 
GeneralRe: can we use wpf controls in window's application . Pin
Anuj Banka6-Oct-09 21:54
Anuj Banka6-Oct-09 21:54 
GeneralRe: can we use wpf controls in window's application . Pin
Christian Graus6-Oct-09 22:11
protectorChristian Graus6-Oct-09 22:11 
GeneralRe: can we use wpf controls in window's application . Pin
Pete O'Hanlon6-Oct-09 22:55
mvePete O'Hanlon6-Oct-09 22:55 
GeneralRe: can we use wpf controls in window's application . Pin
Anuj Banka6-Oct-09 23:11
Anuj Banka6-Oct-09 23:11 
QuestionCustom scrolling in WPF control Pin
grvdarji6-Oct-09 11:51
grvdarji6-Oct-09 11:51 
QuestionRe: Custom scrolling in WPF control Pin
Mark Salsbery7-Oct-09 7:41
Mark Salsbery7-Oct-09 7:41 
AnswerRe: Custom scrolling in WPF control Pin
grvdarji8-Oct-09 5:10
grvdarji8-Oct-09 5:10 
GeneralRe: Custom scrolling in WPF control Pin
Mark Salsbery9-Oct-09 6:26
Mark Salsbery9-Oct-09 6:26 
GeneralRe: Custom scrolling in WPF control Pin
grvdarji9-Oct-09 10:45
grvdarji9-Oct-09 10:45 
QuestionUsing Aero theme in WPF Pin
Etienne_1236-Oct-09 10:59
Etienne_1236-Oct-09 10:59 
AnswerRe: Using Aero theme in WPF Pin
Pete O'Hanlon6-Oct-09 11:14
mvePete O'Hanlon6-Oct-09 11:14 

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.