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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Binding DropDown Items

Thread ID:

Created:

Updated:

Platform:

Replies:

123544 Mar 28,2016 09:35 PM UTC Mar 31,2016 04:06 AM UTC WPF 4
loading
Tags: DropDownButtonAdv
Vladimir Culum
Asked On March 28, 2016 09:35 PM UTC

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

Vijayalakshmi Roopkumar [Syncfusion]
Replied On 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

Vladimir Culum
Replied On 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.

Vladimir Culum
Replied On 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.

Vijayalakshmi Roopkumar [Syncfusion]
Replied On 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.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;