Click here to Skip to main content
15,898,373 members
Home / Discussions / WPF
   

WPF

 
QuestionRe: WPF Applications not running in various machines [URGENT - HELP] Pin
Kunal Chowdhury «IN»15-Sep-09 23:22
professionalKunal Chowdhury «IN»15-Sep-09 23:22 
GeneralRe: WPF Applications not running in various machines [URGENT - HELP] Pin
Kunal Chowdhury «IN»16-Sep-09 1:38
professionalKunal Chowdhury «IN»16-Sep-09 1:38 
GeneralRe: WPF Applications not running in various machines [URGENT - HELP] Pin
Christian Graus16-Sep-09 11:54
protectorChristian Graus16-Sep-09 11:54 
GeneralRe: WPF Applications not running in various machines [URGENT - HELP] Pin
Kunal Chowdhury «IN»16-Sep-09 18:42
professionalKunal Chowdhury «IN»16-Sep-09 18:42 
GeneralRe: WPF Applications not running in various machines [URGENT - HELP] Pin
Kunal Chowdhury «IN»16-Sep-09 19:16
professionalKunal Chowdhury «IN»16-Sep-09 19:16 
AnswerRe: WPF Applications not running in various machines [SOLVED] Pin
Kunal Chowdhury «IN»21-Sep-09 23:11
professionalKunal Chowdhury «IN»21-Sep-09 23:11 
QuestionHow to access UIElements attributes in a column of a datagrid [modified] Pin
rizwan.saddal15-Sep-09 5:24
rizwan.saddal15-Sep-09 5:24 
RantWPF ListBox focus stupidity Pin
Gary Wheeler15-Sep-09 4:23
Gary Wheeler15-Sep-09 4:23 
I've just discovered a bit of WPF ListBox stupidity. If you have a data-bound ListBox, and you set the SelectedItem programmatically, the item you picked is indeed the selected item when the control is displayed. If you use the keyboard to move the selection, however, you find out that the focus item is the first item in the control. On your keypress, the ListBox moves the selection to the first item in the control, rather than the item before/after the previously selected item. Dumb.

Fortunately, the fix is easy. In the Loaded() handler for the container of your ListBox, add the following:
private void _Loaded(object sender, RoutedEventArgs e)
{
    if (List.SelectedIndex >= 0)
    {
        ListBoxItem item = 
            (ListBoxItem)
            List.ItemContainerGenerator.ContainerFromIndex(List.SelectedIndex);
        item.Focus();
    }
    else
    {
        List.Focus();
    }
}
Note that the ListBox instance is named List in this example, and this code assumes that the ListBox has the focus when the window is loaded.

Software Zen: delete this;

QuestionHow to fix components in a Drag & Drop canvas Pin
Nekkantidivya14-Sep-09 22:09
Nekkantidivya14-Sep-09 22:09 
AnswerRe: How to fix components in a Drag & Drop canvas Pin
Arun Jacob15-Sep-09 2:01
Arun Jacob15-Sep-09 2:01 
GeneralRe: How to fix components in a Drag & Drop canvas Pin
Nekkantidivya22-Sep-09 20:53
Nekkantidivya22-Sep-09 20:53 
QuestionSilverlight SDK Pin
CrazyCoder2614-Sep-09 19:43
CrazyCoder2614-Sep-09 19:43 
AnswerRe: Silverlight SDK Pin
Arun Jacob14-Sep-09 20:28
Arun Jacob14-Sep-09 20:28 
GeneralRe: Silverlight SDK Pin
CrazyCoder2614-Sep-09 20:40
CrazyCoder2614-Sep-09 20:40 
AnswerRe: Silverlight SDK Pin
Arun Jacob14-Sep-09 20:48
Arun Jacob14-Sep-09 20:48 
GeneralRe: Silverlight SDK Pin
CrazyCoder2614-Sep-09 21:02
CrazyCoder2614-Sep-09 21:02 
GeneralRe: Silverlight SDK Pin
Arun Jacob15-Sep-09 1:53
Arun Jacob15-Sep-09 1:53 
Questiondatabase connectivity Pin
Aryan198214-Sep-09 12:26
Aryan198214-Sep-09 12:26 
AnswerRe: database connectivity Pin
Arun Jacob14-Sep-09 18:43
Arun Jacob14-Sep-09 18:43 
Questionsilverlight Pin
Aryan198214-Sep-09 12:19
Aryan198214-Sep-09 12:19 
AnswerRe: silverlight Pin
Mark Salsbery15-Sep-09 5:08
Mark Salsbery15-Sep-09 5:08 
QuestionListBox displaying of items problem Pin
Zammy_bg14-Sep-09 4:00
Zammy_bg14-Sep-09 4:00 
AnswerRe: ListBox displaying of items problem Pin
Pete O'Hanlon14-Sep-09 4:42
mvePete O'Hanlon14-Sep-09 4:42 
GeneralRe: ListBox displaying of items problem Pin
Richard MacCutchan14-Sep-09 21:43
mveRichard MacCutchan14-Sep-09 21:43 
GeneralRe: ListBox displaying of items problem Pin
Pete O'Hanlon14-Sep-09 22:59
mvePete O'Hanlon14-Sep-09 22:59 

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.