簡體   English   中英

Datagrid列值綁定?

[英]Datagrid Column value bind?

我只需要在datagrid的列中接受特定的數字,我該如何處理?

<DataGridTextColumn Binding="{Binding Path=SellingPrice, UpdateSourceTrigger=PropertyChanged}">
 <DataGridTextColumn.EditingElementStyle>
  <Style TargetType="{x:Type TextBox}">
     <Setter Property="MaxLength" Value="10"/>
  </Style>
 </DataGridTextColumn.EditingElementStyle>
</DataGridTextColumn>

在上面的代碼中,我給了Value =“ 10”,我需要從ViewModel綁定值,我該怎么做

目前,我無法對此進行測試,但是您可能必須按照自己的風格進行測試:

<Style TargetType="{x:Type TextBox}">
    <Setter Property="MaxLength" Value="{Binding Path=DataContext.MyMaxLength"/>
</Style>

其中MyMaxLength是綁定對象上的屬性。

暫無
暫無

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

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