This project has moved and is read-only. For the latest updates, please go here.

DropDownButton in ListView loses focus

Jan 8, 2014 at 8:16 AM
Hi all,

I am displaying items in ListView (that uses GridView). In one of the GridViewColumn I placed DropDownButton (which will allow setting some parameters).

For testing purpose I placed xceed ColorCanvas as DropDownButton.DropDownContent.

The problem is, that if I click into ColorCanvas DropDown gets closed.
When I click on the sliders or textboxes in ColorCanvas, it works fine. DropDown get closed only when I click to some other place in ColorCanvas.

My xaml looks like this:
<Grid x:Name="LayoutRoot">
    <ListView >
        <ListView.View>
            <GridView>
                <GridViewColumn Header="abc" Width="130">
                    <GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <xcd:DropDownButton Content="#">
                                <xcd:DropDownButton.DropDownContent>
                                    <xcd:ColorCanvas/>
                                </xcd:DropDownButton.DropDownContent>
                            </xcd:DropDownButton>
                        </DataTemplate>
                    </GridViewColumn.CellTemplate>
                </GridViewColumn>
            </GridView>
        </ListView.View>
        <ListViewItem/>
        <ListViewItem/>
        <ListViewItem/>
    </ListView>
</Grid>
Do you have any idea why this happens and how to resolve this issue?

Thank you.
Developer
Jan 8, 2014 at 2:59 PM
Hi,

Maybe it' something to do with the GridView or the ListView. Try handling the event on a mouseDown in the content of the DropDownButton. In this case, in the ColorCanvas :
protected override void OnMouseLeftButtonDown( MouseButtonEventArgs e )
    {
      base.OnMouseLeftButtonDown( e );
      e.Handled = true;
    }
This way, no one will handle the mouseDown when the popup of the DropDownButton is open and clicked.
Marked as answer by _katka on 1/9/2014 at 12:35 AM
Jan 9, 2014 at 8:34 AM
Hi BoucherS,

It works now. Thank you.