Click here to Skip to main content
15,887,214 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Jesús Alvarez Manrique Pin
Member 901299827-Sep-12 7:59
Member 901299827-Sep-12 7:59 
QuestionBobbles in paradise - ViewModel and my personal adventures in WTF Pin
Kenneth Haugland26-Sep-12 18:25
mvaKenneth Haugland26-Sep-12 18:25 
Questionbeginner : binding ListBox Pin
dominioYP26-Sep-12 4:05
dominioYP26-Sep-12 4:05 
AnswerRe: beginner : binding ListBox Pin
Pete O'Hanlon26-Sep-12 4:26
mvePete O'Hanlon26-Sep-12 4:26 
GeneralRe: beginner : binding ListBox Pin
dominioYP26-Sep-12 5:41
dominioYP26-Sep-12 5:41 
GeneralRe: beginner : binding ListBox Pin
dominioYP28-Sep-12 5:38
dominioYP28-Sep-12 5:38 
Questionbeginner : listView, add scrollBar Pin
dominioYP26-Sep-12 3:50
dominioYP26-Sep-12 3:50 
QuestionTrying to set focus on DataGrid with DataGridTemplateColumn Pin
abollmeyer23-Sep-12 3:44
abollmeyer23-Sep-12 3: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:

HTML
<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:

C#
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 14:13
abollmeyer24-Sep-12 14:13 
QuestionOn ContextMenu MouseLeave Pin
Kenneth Haugland21-Sep-12 3:46
mvaKenneth Haugland21-Sep-12 3:46 
AnswerRe: On ContextMenu MouseLeave Pin
Kenneth Haugland21-Sep-12 13:42
mvaKenneth Haugland21-Sep-12 13:42 
QuestionWPF DataGrid Not SHowing Any Data Pin
Kevin Marois20-Sep-12 11:30
professionalKevin Marois20-Sep-12 11:30 
AnswerRe: WPF DataGrid Not SHowing Any Data Pin
Kenneth Haugland20-Sep-12 11:47
mvaKenneth Haugland20-Sep-12 11:47 
GeneralRe: WPF DataGrid Not SHowing Any Data Pin
Pete O'Hanlon20-Sep-12 11:59
mvePete O'Hanlon20-Sep-12 11:59 
GeneralRe: WPF DataGrid Not SHowing Any Data Pin
Kenneth Haugland20-Sep-12 12:10
mvaKenneth Haugland20-Sep-12 12:10 
AnswerRe: WPF DataGrid Not SHowing Any Data Pin
Pete O'Hanlon20-Sep-12 12:01
mvePete O'Hanlon20-Sep-12 12:01 
GeneralRe: WPF DataGrid Not SHowing Any Data Pin
Kevin Marois20-Sep-12 13:23
professionalKevin Marois20-Sep-12 13:23 
GeneralRe: WPF DataGrid Not SHowing Any Data Pin
Pete O'Hanlon20-Sep-12 13:58
mvePete O'Hanlon20-Sep-12 13:58 
Questionstackedbarseries chart: change the axes display Pin
ashlyacht19-Sep-12 10:03
ashlyacht19-Sep-12 10:03 
Question[XML] XML binding Pin
Jayme6519-Sep-12 7:10
Jayme6519-Sep-12 7:10 
Questionplay streaming videos from internet in wpf Pin
sudeep kushwaha17-Sep-12 18:31
sudeep kushwaha17-Sep-12 18:31 
AnswerRe: play streaming videos from internet in wpf Pin
Mycroft Holmes17-Sep-12 20:05
professionalMycroft Holmes17-Sep-12 20:05 
QuestionItemsControl with Horizontal orientation Pin
Kenneth Haugland17-Sep-12 7:25
mvaKenneth Haugland17-Sep-12 7:25 
AnswerRe: ItemsControl with Horizontal orientation Pin
Abhinav S17-Sep-12 7:49
Abhinav S17-Sep-12 7:49 
AnswerRe: ItemsControl with Horizontal orientation Pin
Kenneth Haugland17-Sep-12 8:04
mvaKenneth Haugland17-Sep-12 8:04 

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.