I'm programatically trying to select the newly added line on dataGrid. No fancy stuff, no MVVM, just simple code behind
selected ITem does not matter what I'm doing - I have no clue what is wrong.
XAML:
& lt; Window X: Class = "WpfApplication1.MainWindow" xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns: x = "http://schemas.microsoft.com/winfx/2006/ Xaml "title =" main window "height =" 350 "width =" 525 "& gt; & Lt; Grid & gt; & Lt; DataGrid name = "datagrid" auto generated column = "true" /> & Lt; / Grid & gt; & Lt; / Window & gt; code:
using the system; Using System.Collections.Generic; Using System.Data; Using System.Linq; Using System.Text; System usage threading. Task; Using System.Windows; Using System.Windows.Controls; Using System.Windows.Data; Using System.Windows.Documents; Using System.Windows.Input; System.Windows.Media; System.Windows.Media Using imaging; Using System.Windows.Navigation; Using System.Windows.Shapes; Namespace WpfApplication1 {/// & lt; Summary & gt; /// MainWindow.xaml for Interaction Logic /// & lt; / Summary & gt; Public Partial Class Main Window: Window {Public Main Window () {Initial Group (); // Source for Data Grid Datatyll = New DataTable (); Dt.Columns.Add ("one", typef (string)); Dt.Columns.Add ("two", typef (string)); // Add new line DataRow dr = dt.NewRow (); Dr. [0] = "Uno"; Dr. [1] = "Dos"; Dt.Rows.Add (Dr.); // Choose the new line datagrid. Selected ITem = dr; // DataGrid here. The selected item is still zero, no line is the selected datagrid. ITMSSOS = DATAdataView (); }}}}
So far the data is not available in the rows of the dir, Items for theSource and then set the selected row.
The selected row is actually the object in the grid. Items and if you want to set it as selected, make sure that the referenced similarity is satisfied ..
No comments:
Post a Comment