Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF DatagridRowHeader add button for certain rows not all rows
    primarykey
    data
    text
    <p>I have a WPF datagrid. The datagrid is bound to a list of a custom type called Orders. Currently I have a toggle button for every row in the datagrid. </p> <p>I only want a toggle button to be in the rowheader if the Orders' property MultiID (boolean) is true but can't get this to work. </p> <p>In my DataGridRow I have tried using the commented out section in the line below which seems to make no difference as every row has a toggle button.</p> <pre><code>&lt;Style.Triggers&gt; &lt;Trigger Property="IsMouseOver" Value="True"&gt; &lt;Setter Property="Foreground" Value="Blue"/&gt; &lt;/Trigger&gt; &lt;!--&lt;DataTrigger Binding="{Binding MultiID}" Value="True"&gt; &lt;Setter Property="HeaderTemplate" Value="{StaticResource rowdetailToggleButton}"/&gt; &lt;/DataTrigger&gt;--&gt; &lt;/Style.Triggers&gt; </code></pre> <p>My Datagrid</p> <pre><code>&lt;!-- The data grid to display orders--&gt; &lt;DataGrid DataContext="{Binding OrderBlock}" x:Name="dataGridOrders" ItemsSource="{Binding Orders}" RowStyle="{StaticResource DG_Row}" RowDetailsTemplate="{StaticResource DG_RowDetail}" RowHeaderStyle="{StaticResource DG_RowHeader}" RowDetailsVisibilityChanged="dataGridOrders_RowDetailsVisibilityChanged"&gt; &lt;DataGrid.RowHeaderTemplate&gt; &lt;DataTemplate&gt; &lt;ToggleButton x:Name="RowHeaderToggleButton" Click="RowHeaderToggleButton_Click" Cursor="Hand"/&gt; &lt;DataTemplate.Triggers&gt; &lt;DataTrigger Binding="{Binding Orders.MultiID}" Value="False"&gt; &lt;Setter TargetName="RowHeaderToggleButton" Property="Visibility" Value="Collapsed"/&gt; &lt;/DataTrigger&gt; &lt;/DataTemplate.Triggers&gt; &lt;/DataTemplate&gt; &lt;/DataGrid.RowHeaderTemplate&gt; </code></pre> <p>My DataGridRowHeader</p> <pre><code>&lt;!-- Data Grid row with toggle button --&gt; &lt;Style x:Key="DG_RowHeader" TargetType="{x:Type DataGridRowHeader}"&gt; &lt;Setter Property="Width" Value="35"/&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="{x:Type DataGridRowHeader}"&gt; &lt;Border x:Name="DGRH_Border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="True"&gt; &lt;Border.Background&gt; &lt;LinearGradientBrush StartPoint="0,0" EndPoint="1,1"&gt; &lt;GradientStop Offset="0" Color="LightGray"/&gt; &lt;GradientStop Offset="1" Color="WhiteSmoke"/&gt; &lt;/LinearGradientBrush&gt; &lt;/Border.Background&gt; &lt;ContentPresenter Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/&gt; &lt;/Border&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre> <p>My DataGridRow</p> <pre><code> &lt;!-- Data grid formatting Grid Row template --&gt; &lt;Style x:Key="DG_Row" TargetType="{x:Type DataGridRow}"&gt; &lt;Setter Property="Opacity" Value="1"/&gt; &lt;Setter Property="Padding" Value="3,2,2,3"/&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="{x:Type DataGridRow}"&gt; &lt;Border x:Name="DGR_Border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="True"&gt; &lt;Border.Background&gt; &lt;LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"&gt; &lt;GradientStop Offset="0" Color="Transparent"/&gt; &lt;GradientStop Offset="1" Color="Silver"/&gt; &lt;/LinearGradientBrush&gt; &lt;/Border.Background&gt; &lt;/Border&gt; &lt;ControlTemplate.Triggers&gt; &lt;DataTrigger Binding="{Binding StatusGood}" Value="Send"&gt; &lt;Setter TargetName="DGR_Border" Property="Background" Value="{StaticResource brushRowSend}"/&gt; &lt;/DataTrigger&gt; &lt;/ControlTemplate.Triggers&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;Style.Triggers&gt; &lt;Trigger Property="IsMouseOver" Value="True"&gt; &lt;Setter Property="Foreground" Value="Blue"/&gt; &lt;/Trigger&gt; &lt;!--&lt;DataTrigger Binding="{Binding MultiID}" Value="True"&gt; &lt;Setter Property="HeaderTemplate" Value="{StaticResource rowdetailToggleButton}"/&gt; &lt;/DataTrigger&gt;--&gt; &lt;/Style.Triggers&gt; &lt;/Style&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload