簡體   English   中英

MahApps Metro如何將DropDownMenu綁定到父DataGrid屬性?

[英]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.

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