[英]MahApps Metro how to bind DropDownMenu to parent DataGrid property?
我有一個DataGrid
,其中一列是模板列,其中包含MahApps Metro提供的DropDownMenu
。 我成功填充了ItemsSource
並且在單擊菜單時顯示了項目。
我現在將這個選擇的值綁定到datagrid項目源時遇到了問題。
到目前為止,我已經嘗試過:
<Controls:DropDownButton ItemsSource="{Binding ResTypes, RelativeSource={RelativeSource AncestorType=Window}}" Content="{Binding Type, RelativeSource={RelativeSource AncestorType=DataGrid}, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
每當我選擇一個項目時,它的值甚至在DropDownMenu
上都不會改變,就像它甚至無法被選擇一樣。
我該如何解決? 謝謝
DropDownButton
沒有選擇的概念。 您應該使用SplitButton
並將其SelectedItem
屬性綁定到您的source屬性。
雖然內置的DataGrid
沒有Type
屬性,所以尚不清楚您要綁定的屬性。 確保ResTypes
集合中項目的Type
與您要綁定到的Type
屬性相同。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.