title: WPF show data in another window from datagrid
body: <p>I have a datagrid in mainwindow and there is a detail button in datagrid . I wanna click detail button show data(row) in another window. Only Textblocks.</p>
  
  <p><a href="https://i.stack.imgur.com/GHe8T.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GHe8T.png" alt="enter image description here"></a></p>
  
  <p>Grid XAML</p>
  
  <pre><code>    &lt;DataGrid x:Name="dataGrid1" Grid.Column="1" Grid.Row="1" RowHeaderWidth="0" BorderBrush="{x:Null}" FontSize="14" FontFamily="Verdana" CanUserResizeRows="False" IsReadOnly="True" RowDetailsVisibilityMode="Visible" ClipboardCopyMode="None" AutoGenerateColumns="False" CanUserReorderColumns="False" CanUserSortColumns="False" AutomationProperties.IsColumnHeader="True" AutomationProperties.IsOffscreenBehavior="Onscreen" CellStyle="{DynamicResource DataGridCellStyle1}" CanUserResizeColumns="False" GridLinesVisibility="Horizontal" HorizontalGridLinesBrush="#FF0194CA" Foreground="Black" HorizontalScrollBarVisibility="Disabled" Background="{x:Null}" UseLayoutRounding="False" VerticalScrollBarVisibility="Visible" SelectionMode="Single"&gt;
          &lt;DataGrid.Columns&gt;
              &lt;DataGridTemplateColumn Header="Başlık" Width="500" CanUserResize="False"&gt;
                  &lt;DataGridTemplateColumn.CellTemplate&gt;
                      &lt;DataTemplate&gt;
                          &lt;TextBlock Text="{Binding Path=baslik}"  FontSize="13" TextWrapping="Wrap" Padding="10" Background="{x:Null}"/&gt;
                      &lt;/DataTemplate&gt;
                  &lt;/DataGridTemplateColumn.CellTemplate&gt;
              &lt;/DataGridTemplateColumn&gt;
              &lt;DataGridTemplateColumn Header="Büyüklük" Width="100" CanUserResize="False"&gt;
                  &lt;DataGridTemplateColumn.CellTemplate&gt;
                      &lt;DataTemplate&gt;
                          &lt;TextBlock Text="{Binding Path=metrekare}" FontSize="13" TextWrapping="Wrap" Padding="10"/&gt;
                      &lt;/DataTemplate&gt;
                  &lt;/DataGridTemplateColumn.CellTemplate&gt;
              &lt;/DataGridTemplateColumn&gt;
              &lt;DataGridTemplateColumn Header="Konum" Width="196" CanUserResize="False"&gt;
                  &lt;DataGridTemplateColumn.CellTemplate&gt;
                      &lt;DataTemplate&gt;
                          &lt;TextBlock Text="{Binding Path=mevkii}" FontSize="13" TextWrapping="Wrap" Padding="10"/&gt;
                      &lt;/DataTemplate&gt;
                  &lt;/DataGridTemplateColumn.CellTemplate&gt;
              &lt;/DataGridTemplateColumn&gt;
              &lt;DataGridTemplateColumn Header="Detay" CanUserResize="False" Width="Auto"&gt;
                  &lt;DataGridTemplateColumn.CellTemplate&gt;
                      &lt;DataTemplate&gt;
                          &lt;Button Content="Ilan Detayları" Click="DetayButton_Click" FontSize="13" FontFamily="Verdana" Padding="10" Margin="0,10,26,10" /&gt;
                      &lt;/DataTemplate&gt;
                  &lt;/DataGridTemplateColumn.CellTemplate&gt;
              &lt;/DataGridTemplateColumn&gt;
          &lt;/DataGrid.Columns&gt;
      &lt;/DataGrid&gt;
  </code></pre>
  
  <p>MainWindow Datagrid Process</p>
  
  <pre><code>    private void Window_Loaded(object sender, RoutedEventArgs e)
      {
          SQLiteConnection yeni = new SQLiteConnection(baglanti);
          yeni.Open();
  
          string sorgu = "Select * From Gayrimenkul";
  
          // SQLiteCommand komutislet = new SQLiteCommand(sorgu,baglanti);
          DataSet dataSet = new DataSet();
          SQLiteDataAdapter dataAdapter = new SQLiteDataAdapter(sorgu, baglanti);
          dataAdapter.Fill(dataSet);
  
          dataGrid1.ItemsSource = dataSet.Tables[0].DefaultView;
          yeni.Close();
  
      }
  </code></pre>