Auto-Drop down of combo box in DevExpress Xpf.Grid when clicking from one combo box to another

1.2k views Asked by At

I am trying to enable 1-click editing of dropdown combo boxes inside a DevExpress.Xpf.Grid, and am running into a rather unusual problem that I've not been able to find a solution to;

I want to be able to:

  1. click on any cell that contains a combo box and have the 'Editor' immediately show the combo-box in the open state
  2. then while the combo box is still open, click onto another cell, the current combo box should close, and the new one I just clicked should open (with combo-box open). enter image description here

For example; If I clicked on cell A (To Paris), and then saw that it was the wrong cell, and immediately click Cell B(From Vienna) to it's left, what happens is that the second click appears to be captured as some type of 'close-combo' or escape event, and combo A (To Paris) closes, and the mouse click or mouse-down or previewMouseXX event is never captured anywhere else. i.e. while I've actually clicked on (From Vienna) that combo box never opens. If another combobox is already open then I actually have to double click to open cell B despite cell B being configured with immediatePopup="true".

I've tried a bunch of approaches with no luck. (They all focus on getting the first cell I click to automatically open, and that works, but only for the first cell. )

Any assistance at all will be hugely appreciated.

txs,

Alan

here's some sample code that demonstrates the problem;

<Window 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:Grid1"
        x:Class="Grid1.MainWindow"

        xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors" 
        xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"  

        Title="Trip Details" Height="350" Width="625">

    <Window.DataContext>
        <local:MainWindowViewModel/>
    </Window.DataContext>

    <Grid>
        <dxg:TableView>
        </dxg:TableView>
        <dxg:GridControl ItemsSource="{Binding Customers}">
            <dxg:GridControl.Columns>

                <dxg:GridColumn FieldName="Name"/>

                <dxg:GridColumn FieldName="From">
                    <dxg:GridColumn.EditSettings>
                        <dxe:ComboBoxEditSettings ImmediatePopup="True" ItemsSource="{Binding Cities}" AutoComplete="True" IsTextEditable="False" DisplayMember="Name" ValueMember="Id"/>
                    </dxg:GridColumn.EditSettings>
                </dxg:GridColumn>

                <dxg:GridColumn FieldName="To">
                    <dxg:GridColumn.EditSettings>
                        <dxe:ComboBoxEditSettings  ImmediatePopup="True" ItemsSource="{Binding Cities}" AutoComplete="True" IsTextEditable="False" DisplayMember="Name" ValueMember="Id"/>
                    </dxg:GridColumn.EditSettings>
                </dxg:GridColumn>

                <dxg:GridColumn FieldName="Depart"/>
                <dxg:GridColumn FieldName="Return"/>

            </dxg:GridControl.Columns>
        </dxg:GridControl>
    </Grid>
</Window>

City class;

namespace Grid1
{
    public class City
    {
        public int Id { get; set; }
        public string Name { get; set; }

        public static List<City> GetCities()
        {
            return new List<City>()
            {
                new City() { Id = 1, Name = "London"},
                new City() { Id = 2, Name = "Paris"},
                new City() { Id = 3, Name = "Vienna"},
                new City() { Id = 4, Name = "Cambridge"}
            };
        }
    }

    public enum  CityId {  London = 1, Paris, Vienna, Cambridge }
}

and the viewmodel;

namespace Grid1
{
    public class MainWindowViewModel
    {
        public MainWindowViewModel()
        {
            Customers = Trip.GetCustomers();
            Cities = City.GetCities();
        }

        public List<Trip> Customers { get; set; }
        public List<City> Cities { get; set; }
    }
}

Summary:

When a combobox has just opened as a result of a single-click (this works), when clicking away (immediately onto a second cell in order to get that cell to show it's combobox, that doesnt work), it's almost as if that click is turned into some type of click-away event, if such a thing even exists, and where you actually clicked is ignored and hit-testing at that spot is never done, and no further mouse event is raised. That new cell you clicked never even receives any focus or events. (as if the combo box swallowed the click)

0

There are 0 answers