Click here to Skip to main content
12,701,301 members (31,479 online)

Silverlight / WPF

 
GeneralRe: New to .net/ previous programming background Pin
Alisaunder3-Oct-12 18:10
memberAlisaunder3-Oct-12 18:10 
AnswerRe: New to .net/ previous programming background Pin
_Maxxx_7-Oct-12 18:17
member_Maxxx_7-Oct-12 18:17 
QuestionJesús Alvarez Manrique Pin
Member 901299827-Sep-12 7:47
memberMember 901299827-Sep-12 7:47 
AnswerRe: Jesús Alvarez Manrique Pin
Yayozama27-Sep-12 8:37
memberYayozama27-Sep-12 8:37 
GeneralRe: Jesús Alvarez Manrique Pin
Member 901299827-Sep-12 8:57
memberMember 901299827-Sep-12 8:57 
GeneralRe: Jesús Alvarez Manrique Pin
Emmanuel Medina Lopez27-Sep-12 12:33
memberEmmanuel Medina Lopez27-Sep-12 12:33 
GeneralRe: Jesús Alvarez Manrique Pin
Member 901299827-Sep-12 8:59
memberMember 901299827-Sep-12 8:59 
QuestionBobbles in paradise - ViewModel and my personal adventures in WTF Pin
Kenneth Haugland26-Sep-12 19:25
memberKenneth Haugland26-Sep-12 19:25 
Questionbeginner : binding ListBox Pin
dominioYP26-Sep-12 5:05
memberdominioYP26-Sep-12 5:05 
AnswerRe: beginner : binding ListBox Pin
Pete O'Hanlon26-Sep-12 5:26
protectorPete O'Hanlon26-Sep-12 5:26 
GeneralRe: beginner : binding ListBox Pin
dominioYP26-Sep-12 6:41
memberdominioYP26-Sep-12 6:41 
GeneralRe: beginner : binding ListBox Pin
dominioYP28-Sep-12 6:38
memberdominioYP28-Sep-12 6:38 
Questionbeginner : listView, add scrollBar Pin
dominioYP26-Sep-12 4:50
memberdominioYP26-Sep-12 4:50 
QuestionTrying to set focus on DataGrid with DataGridTemplateColumn Pin
abollmeyer23-Sep-12 4:44
memberabollmeyer23-Sep-12 4:44 
Hello, I have a DataGrid that I am using where the user clicks a button to add information to the DataGrid. I would like to set focus to the first cell when the user clicks the button. My previous code worked great in a plain ol' DataGridTextColumn, but no longer works.

Here is my XAML:

<DataGrid.Columns>
                    <DataGridTemplateColumn x:Name="partName" 
                                             Header="Part Name" 
                                             CanUserResize="True" 
                                             Width="225" 
                                             MinWidth="225">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock VerticalAlignment="Center" Focusable="True" FocusManager.FocusedElement="{Binding RelativeSource={RelativeSource Self}}">
                                    <Hyperlink NavigateUri="http://www.bing.com"
                                               RequestNavigate="Hyperlink_RequestNavigate"
                                               TextDecorations="None">
                                        <TextBlock Text="{Binding Path=description}" x:Name="hyperLinkTextBlock"
                                                   FontSize="20" 
                                                   FontWeight="Black" 
                                                   TextWrapping="WrapWithOverflow"
                                                   TextDecorations="Underline" 
                                                   Focusable="True"
                                                   FocusManager.FocusedElement="{Binding RelativeSource={RelativeSource Self}}"/>
                                    </Hyperlink>                                        
                                </TextBlock>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                        <DataGridTemplateColumn.CellEditingTemplate>
                            <DataTemplate>
                                <TextBox FontSize="20" 
                                         FontWeight="Black" 
                                         HorizontalAlignment="Stretch"          
                                         VerticalContentAlignment="Center"/>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellEditingTemplate>
                    </DataGridTemplateColumn>
 


And here is my C# code:

partsDataGrid.Focus();
                partsDataGrid.UpdateLayout();
                DataGridCellInfo cellInfo = new DataGridCellInfo (partsDataGrid.Items[0], partsDataGrid.Columns[0]);
                partsDataGrid.CurrentCell = cellInfo;

                partsDataGrid.BeginEdit();



What am I doing wrong? Thanks in advance!
AnswerRe: Trying to set focus on DataGrid with DataGridTemplateColumn Pin
abollmeyer24-Sep-12 15:13
memberabollmeyer24-Sep-12 15:13 
QuestionOn ContextMenu MouseLeave Pin
Kenneth Haugland21-Sep-12 4:46
memberKenneth Haugland21-Sep-12 4:46 
AnswerRe: On ContextMenu MouseLeave Pin
Kenneth Haugland21-Sep-12 14:42
memberKenneth Haugland21-Sep-12 14:42 
QuestionWPF DataGrid Not SHowing Any Data Pin
Kevin Marois20-Sep-12 12:30
memberKevin Marois20-Sep-12 12:30 
AnswerRe: WPF DataGrid Not SHowing Any Data Pin
Kenneth Haugland20-Sep-12 12:47
memberKenneth Haugland20-Sep-12 12:47 
GeneralRe: WPF DataGrid Not SHowing Any Data Pin
Pete O'Hanlon20-Sep-12 12:59
protectorPete O'Hanlon20-Sep-12 12:59 
GeneralRe: WPF DataGrid Not SHowing Any Data Pin
Kenneth Haugland20-Sep-12 13:10
memberKenneth Haugland20-Sep-12 13:10 
AnswerRe: WPF DataGrid Not SHowing Any Data Pin
Pete O'Hanlon20-Sep-12 13:01
protectorPete O'Hanlon20-Sep-12 13:01 
GeneralRe: WPF DataGrid Not SHowing Any Data Pin
Kevin Marois20-Sep-12 14:23
memberKevin Marois20-Sep-12 14:23 
GeneralRe: WPF DataGrid Not SHowing Any Data Pin
Pete O'Hanlon20-Sep-12 14:58
protectorPete O'Hanlon20-Sep-12 14:58 
Questionstackedbarseries chart: change the axes display Pin
ashlyacht19-Sep-12 11:03
memberashlyacht19-Sep-12 11:03 
Question[XML] XML binding Pin
Jayme6519-Sep-12 8:10
memberJayme6519-Sep-12 8:10 
Questionplay streaming videos from internet in wpf Pin
sudeep kushwaha17-Sep-12 19:31
membersudeep kushwaha17-Sep-12 19:31 
AnswerRe: play streaming videos from internet in wpf Pin
Mycroft Holmes17-Sep-12 21:05
memberMycroft Holmes17-Sep-12 21:05 
QuestionItemsControl with Horizontal orientation Pin
Kenneth Haugland17-Sep-12 8:25
memberKenneth Haugland17-Sep-12 8:25 
AnswerRe: ItemsControl with Horizontal orientation Pin
Abhinav S17-Sep-12 8:49
mvpAbhinav S17-Sep-12 8:49 
AnswerRe: ItemsControl with Horizontal orientation Pin
Kenneth Haugland17-Sep-12 9:04
memberKenneth Haugland17-Sep-12 9:04 
GeneralRe: ItemsControl with Horizontal orientation Pin
Abhinav S17-Sep-12 18:25
mvpAbhinav S17-Sep-12 18:25 
GeneralRe: ItemsControl with Horizontal orientation Pin
Kenneth Haugland17-Sep-12 21:24
memberKenneth Haugland17-Sep-12 21:24 
AnswerRe: ItemsControl with Horizontal orientation Pin
Kenneth Haugland17-Sep-12 10:35
memberKenneth Haugland17-Sep-12 10:35 
QuestionWPF Editable ComboxBox Question Pin
Kevin Marois14-Sep-12 11:46
memberKevin Marois14-Sep-12 11:46 
AnswerRe: WPF Editable ComboxBox Question Pin
SledgeHammer0114-Sep-12 12:17
memberSledgeHammer0114-Sep-12 12:17 
GeneralRe: WPF Editable ComboxBox Question Pin
Kevin Marois15-Sep-12 18:21
memberKevin Marois15-Sep-12 18:21 
GeneralRe: WPF Editable ComboxBox Question Pin
SledgeHammer0116-Sep-12 8:18
memberSledgeHammer0116-Sep-12 8:18 
GeneralRe: WPF Editable ComboxBox Question Pin
Kevin Marois16-Sep-12 9:55
memberKevin Marois16-Sep-12 9:55 
GeneralRe: WPF Editable ComboxBox Question Pin
SledgeHammer0116-Sep-12 10:14
memberSledgeHammer0116-Sep-12 10:14 
GeneralRe: WPF Editable ComboxBox Question Pin
Kevin Marois16-Sep-12 10:31
memberKevin Marois16-Sep-12 10:31 
GeneralRe: WPF Editable ComboxBox Question Pin
SledgeHammer0116-Sep-12 11:15
memberSledgeHammer0116-Sep-12 11:15 
GeneralRe: WPF Editable ComboxBox Question Pin
Kevin Marois16-Sep-12 11:25
memberKevin Marois16-Sep-12 11:25 
QuestionWPF Datagrid linked to URL Pin
abollmeyer13-Sep-12 19:14
memberabollmeyer13-Sep-12 19:14 
AnswerRe: WPF Datagrid linked to URL Pin
Pete O'Hanlon13-Sep-12 21:52
protectorPete O'Hanlon13-Sep-12 21:52 
GeneralRe: WPF Datagrid linked to URL Pin
abollmeyer13-Sep-12 23:50
memberabollmeyer13-Sep-12 23:50 
GeneralRe: WPF Datagrid linked to URL Pin
Pete O'Hanlon14-Sep-12 0:23
protectorPete O'Hanlon14-Sep-12 0:23 
GeneralRe: WPF Datagrid linked to URL Pin
abollmeyer14-Sep-12 22:42
memberabollmeyer14-Sep-12 22:42 
QuestionUN Register Scriptable Object Pin
Marc Vandeputte13-Sep-12 8:07
memberMarc Vandeputte13-Sep-12 8:07 
AnswerRe: UN Register Scriptable Object Pin
Clifford Nelson13-Sep-12 9:34
memberClifford Nelson13-Sep-12 9:34 

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.


Advertise | Privacy | Mobile
Web02 | 2.8.170118.1 | Last Updated 23 Jan 2017
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid