Adding a Button to a WPF DataGrid -


I want to create a DataGrid control in WPF that has a button in the first cell of each row Clicking on this button will show RowDetailsTemplate or SubRow.

/ Div>

Create DataGridTemplateColumn to include the first button:

  & Lt; DataGridTemplateColumn & gt; & Lt; DataGridTemplateColumn.CellTemplate & gt; & Lt; DataTemplate & gt; & Lt; Button click = "ShowHideDetails" & gt; Details & lt; / Button & gt; & Lt; / DataTemplate & gt; & Lt; /DataGridTemplateColumn.CellTemplate> & Lt; / DataGridTemplateColumn & gt;  

When the button is clicked, enter DataGridRow of DetailsVisibility :

  to zero Update ShowHideDetails (for object sender, RoutedEventArgs E) {as (VisVis = Sender view; Vis! = Empty; vis = as VisualTreeHelper.GetParent (VIS)) if (vis DataGridRow) {var line = ( DataGridRow); Line. Detailed Description = Row Detailed description == Visibility. Visible? Visibility Collapsed: Visibility. Visible; break; }}  

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -