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
Post a Comment