簡體   English   中英

WPF禁用DataGrid單元

[英]WPF disable DataGrid Cell

我想基於數據庫返回的程序禁用[只讀] DataGridCell 我正在使用以下代碼,但無法正常工作

<DataGridTextColumn Width="SizeToCells" x:Name="amountColumn" Header="Amount"  Binding="{Binding Amount}"  MinWidth="100" >
    <DataGridTextColumn.CellStyle>
         <Style TargetType="DataGridCell">
             <Style.Triggers>
                 <DataTrigger Binding="{Binding RoleName}" Value="Payment Authoriser" >
                     <Setter Property="Background" Value="#DDA0DC" />
                     <Setter Property="ToolTip" Value="Please Add Amount" />
                 </DataTrigger>
             </Style.Triggers>
         </Style>
     </DataGridTextColumn.CellStyle>
 </DataGridTextColumn>
 <Setter Property="DedableThisCell" Value="Please DesableMe" />

GridCell將只有寫在RoleName="Payment Maker"的還有什么別的RoleName ,這將是只讀的。

你嘗試過這樣的事情嗎?

<DataTrigger Binding="{Binding RoleName}" Value="Payment Maker" >
        <Setter Property="IsEnabled" Value="True" />
</DataTrigger>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM