We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Binding DropDown Items

Hello,

I am using DropDownButtonAdv in my View. I made one ViewModel per View, and other bindings on View is working.
How to bind items to the DropDownButtonAdv.

Binding needs to have Header, Command and CommandParameter.

I have class of BtnItem (Header string, Command ICommand, CommandParameter string) that is populating from db.

On my ViewModel, I have ObservableCollection<BtnItem> ItemsCollection that I want to bind.

My Collection is filling, but I can not bind items in xaml.

I try with Style

<syncfusion:DropDownMenuGroup ItemsSource="{Binding ItemsCollection}">
                    <syncfusion:DropDownMenuGroup.ItemContainerStyle>
                        <Style TargetType="{x:Type syncfusion:DropDownMenuItem}">
                            <Setter Property="syncfusion:DropDownMenuItem.Header" Value="{Binding ItemsCollection.Header}" />
...


I am getting error that {"A style intended for type 'DropDownMenuItem' cannot be applied to type 'ContentPresenter'."}

Can somebody help me with this issue that I have?

Thank You,
Vladimir

4 Replies

VR Vijayalakshmi Roopkumar Syncfusion Team March 29, 2016 12:08 PM UTC

Hi Vladimir,

Thank you for using Syncfusion Products,

Query#1: How to bind items to the DropDownButtonAdv.

We have prepared a simple sample that tries to meet your requirement. In our sample, we bind the item and apply the Itemtemplate for DropDownButtonAdv, to bind it. Please download the sample from the following attachment.

Query#2: I am getting error that {"A style intended for type 'DropDownMenuItem' cannot be applied to type 'ContentPresenter'."}

Since, our DropDownMenuGroup not only accepts the Menuitems but also the Button,TextBlock as a child, you have to apply the ItemContainerStyle by setting its TargetType as ContentPresenter. You can edit the controltemplate of ContentPresenter as per your desire to apply the style to the DropDownMenuItems.

Regards,
Vijayalakshmi V.R.

Attachment: DropDownButtonAdv_123544_3b6a899d.zip


VC Vladimir Culum March 30, 2016 09:46 AM UTC

Vijayalakshmi,

Thank You for the response.

I made button and bind Header, Command and CommandParameter to it.

Everything is working fine.


VC Vladimir Culum March 30, 2016 09:46 AM UTC

Vijayalakshmi,

Thank You for the response.

I made button and bind Header, Command and CommandParameter to it.

Everything is working fine.


VR Vijayalakshmi Roopkumar Syncfusion Team March 31, 2016 04:06 AM UTC

Hi Vladimir,

Thank you for the update,

Please let us know if you need any further assistance on this,

Regards,
Vijayalakshmi V.R.

Loader.
Live Chat Icon For mobile
Up arrow icon