WPF DataGrid Button Column Disabled

Can I disable a button in a DataGridTemplateColumn? I have a DataGridTemplate as follows:

<toolkit:DataGridTemplateColumn Header="Timer" Width="50">
                    <toolkit:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Button Content="Start" Click="Button_Click" CommandParameter="{Binding}" />
                        </DataTemplate>
                    </toolkit:DataGridTemplateColumn.CellTemplate>
                </toolkit:DataGridTemplateColumn>

The purpose of the button is to start a timer recorded on the object associated with this line. My timer code works fine, but I would also like to disable the buttons on any other line so that you can only work on one timer.

I used

WorkItemGrid.Columns[WorkItemGrid.Columns.Count - 1].GetCellContent(item).IsEnabled = false

to disable it, and all the buttons are displayed correctly, but if you double-click the button, it will be re-installed and will allow you to click on it a third time and trigger the Click event. Is it possible to actually disable the button?

+3
source share
3 answers

, Datagrid IsEnabled, . , , false. .

"", , .

+2

, , Button.IsEnabled , false , true .

, , , . , , ( , ).

0
its not working in my case. 

                                      <DataGridTemplateColumn Width="70" Header="Refund" >
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <Button x:Name="btnRefundGame" IsEnabled="{Binding RESUND_STATUS}" CommandParameter="{Binding Path=IDEN_LOGID}" Content="Refund" Click="btnRefundGame_Click"   ></Button>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn> 
0
source

Source: https://habr.com/ru/post/1704592/


All Articles