简体   繁体   中英

MahApps Metro how to bind DropDownMenu to parent DataGrid property?

I have a DataGrid and one of the columns is a template column which contains DropDownMenu from MahApps Metro. I successfully populate ItemsSource and items are displayed when menu is clicked.

I'm having problem now binding this selected value to datagrid items source.

I've tried so far:

<Controls:DropDownButton ItemsSource="{Binding ResTypes, RelativeSource={RelativeSource AncestorType=Window}}" Content="{Binding Type, RelativeSource={RelativeSource AncestorType=DataGrid}, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>

And whenever I select an item, the value doesn't even change on DropDownMenu , like it item can't even be selected.

How could I solve this? Thanks

The DropDownButton has no concept of selection. You should use a SplitButton and bind its SelectedItem property to your source property.

The built-in DataGrid has no Type property though so it's unclear to what property you are trying to bind. Make sure that the type of the items in the ResTypes collection is the same as the Type property that you are trying to bind to.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM