Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to add Comboboxes to all ColumnHedares in Datagrid except for the first column in wpf?
    primarykey
    data
    text
    <p>I have a datagrid which I have replaced the headers with Comboboxes. I got this part working by using the below code in wpf, but my problem is I don't want to have the combobox for the first column header.</p> <p>I have tried this way :</p> <pre><code>&lt;DataGrid.ColumnHeaderStyle&gt; &lt;Style TargetType="{x:Type DataGridColumnHeader}"&gt; &lt;EventSetter Event="Click" Handler="ColumnHeaderClick" /&gt; &lt;Style.Triggers&gt; &lt;DataTrigger Value="True"&gt; &lt;DataTrigger.Binding&gt; &lt;MultiBinding Converter="{StaticResource ColumnHeaderToComboBoxConverter}"&gt; &lt;Binding Path="ColumnHeader"/&gt; &lt;Binding Path="DataContext.FirstColumnHeader" ElementName="control" /&gt; &lt;/MultiBinding&gt; &lt;/DataTrigger.Binding&gt; &lt;Setter Property="ContentTemplate"&gt; &lt;Setter.Value&gt; &lt;DataTemplate&gt; &lt;ComboBox ItemsSource="{Binding DataContext.ArticleAttributes, Source={x:Reference control}}"&gt; &lt;l:Interaction.Triggers&gt; &lt;l:EventTrigger EventName="SelectionChanged"&gt; &lt;l:InvokeCommandAction Command="{Binding DataContext.ArticleAttributeCommand, Source={x:Reference control}}" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ComboBox}}, Path=SelectedItem}" /&gt; &lt;/l:EventTrigger&gt; &lt;/l:Interaction.Triggers&gt; &lt;/ComboBox&gt; &lt;/DataTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/DataTrigger&gt; &lt;/Style.Triggers&gt; &lt;/Style&gt; &lt;/DataGrid.ColumnHeaderStyle&gt; </code></pre> <p>In the <strong>Multibinding</strong> part, I want to send in 2 values to the converter :</p> <p>As the first value I am trying to send the current column header :</p> <pre><code>&lt;Binding Path="ColumnHeader"/&gt; </code></pre> <p>And as the second value every time I send in a specific value which is the first column header: </p> <pre><code>&lt;Binding Path="DataContext.FirstColumnHeader" ElementName="control" /&gt; </code></pre> <p>I want to compare these two in the converter if they are they same then return false otherwise it should return true (It means add the combo box to column header). But the <strong></strong> does not send in any information to the converter which is named : ColumnHeaderToComboBoxConverter.</p> <p>Any help will be appreciated.<img src="https://i.stack.imgur.com/IkRlS.png" alt="enter image description here"></p> <p>I have attached an Image also.</p>
    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.
    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