![](/img/trans.png)
[英]How to bind Wpf datagrid to dynamically created column name,value pairs?
[英]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.