This project has moved. For the latest updates, please go here.

DropDownButton content binding issue

Feb 16, 2012 at 1:38 PM
Edited Feb 16, 2012 at 1:39 PM


I'm trying to add MenuItems into a DropDropButton control and control the visibility 
of the buttons using the IsSelected property of TabItem, however the visibility 
of the MenuItems do not change. I applied the same binding on a standard 
button it the visibility works as expected. Does anyone know what is going on here?

Here is a sample of what I'm trying to do:

        <Button Content="Hi" Visibility="{Binding ElementName=tabItem1, Path=IsSelected, Converter={StaticResource VisibilityConverter}}"/>
        <toolkitEx:DropDownButton Content="Button 1">
                    <MenuItem Header="Visibile for tabItem1" Visibility="{Binding ElementName=tabItem1, Path=IsSelected, Converter={StaticResource VisibilityConverter}}"/>
                    <MenuItem Header="Visibile for tabItem2" Visibility="{Binding ElementName=tabItem2, Path=IsSelected, Converter={StaticResource VisibilityConverter}}"/>
        <TabControl HorizontalAlignment="Stretch" Name="tabControl1" VerticalAlignment="Stretch" >
            <TabItem Header="tabItem1" x:Name="tabItem1">
                <Grid />
            <TabItem Header="tabItem2" x:Name="tabItem2">
                <Grid />



Feb 17, 2012 at 5:05 PM

My computer is broken so I can't test your scenario, but I am assuming it is because the items you placed in the DropDownContent aren't created until they are shown.  The DropDownContent are elements in a popup.  After the popup is opened then the content within the popup will be created.  Try handling the tab changes events and programatically changing the visibility of the menu items.  If the menu items are null before you initially opened the popup the my assumption was correct.