Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9215125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:08:01+00:00 2026-06-18T02:08:01+00:00

I want to use the DataGridComboBoxColumn as a autocomplete combobox. I’ve got it partially

  • 0

I want to use the DataGridComboBoxColumn as a autocomplete combobox.

I’ve got it partially working. When the Row is in EditMode I can type text in the ComboBox, also in ViewMode the control returns the text. Only how to get the Label (in template) to EditMode by mouse doubleclick?

Up front, I don’t want to use the DataGridTemplateColumn control because it just doesn’t handle keyboard and mouse entry like the DataGridComboBoxColumn does (tabs, arrows, edit/view mode/ double click etc..).

It looks like:

app

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T02:08:03+00:00Added an answer on June 18, 2026 at 2:08 am

    I fixed it adding a behavior to the TextBox to get a link to the parent DataGrid then setting the Row into Edit Mode by calling BeginEdit().

    The solution I used:

    View

    <Window x:Class="WpfApplication1.MainWindow"
            xmlns:local="clr-namespace:WpfApplication1"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
        <Window.Resources>
            <local:BindingProxy x:Key="proxy" Data="{Binding}" />
        </Window.Resources>
        <Grid>
            <DataGrid ItemsSource="{Binding Model.Things}" Name="MyGrid" ClipboardCopyMode="IncludeHeader">
                <DataGrid.Resources>
    
                </DataGrid.Resources>
                <DataGrid.Columns>
                    <DataGridComboBoxColumn Header="Object" MinWidth="140" TextBinding="{Binding ObjectText}" ItemsSource="{Binding Source={StaticResource proxy}, Path=Data.Model.ObjectList}" >
                        <DataGridComboBoxColumn.EditingElementStyle>
                            <Style TargetType="ComboBox">
                                <Setter Property="IsEditable" Value="True"/>
                                <Setter Property="Text" Value="{Binding ObjectText}"/>
                                <Setter Property="IsSynchronizedWithCurrentItem" Value="True" />
                            </Style>
                        </DataGridComboBoxColumn.EditingElementStyle>
                        <DataGridComboBoxColumn.ElementStyle>
                            <Style TargetType="ComboBox">
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate>
                                            <TextBox IsReadOnly="True" Text="{Binding Path=DataContext.ObjectText, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGridRow}}}">
                                                <TextBox.Resources>
                                                    <Style TargetType="{x:Type TextBox}">
                                                        <Setter Property="local:CellSelectedBehavior.IsCellRowSelected" Value="true"></Setter>
                                                    </Style>
                                                </TextBox.Resources>
                                            </TextBox>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </DataGridComboBoxColumn.ElementStyle>
                    </DataGridComboBoxColumn>
                </DataGrid.Columns>
            </DataGrid>
        </Grid>
    </Window>
    

    Model

    public class Model : BaseModel
    {
        //List of objects for combobox
        private List<string> _objectList;
        public List<string> ObjectList { get { return _objectList; } set { _objectList = value; } }
    
        //Rows in datagrid
        private List<Thing> _things;
        public List<Thing> Things
        {
            get { return _things; }
            set { _things = value; OnPropertyChanged("Things"); }
        }
    }
    
    public class Thing : BaseModel
    {
        //Text in combobox
        private string _objectText;
        public string ObjectText
        {
            get { return _objectText; }
            set { _objectText = value; OnPropertyChanged("ObjectText"); }
        }
    }
    

    ViewModel

    public class ViewModel
    {
        public Model Model { get; set; }
    
        public ViewModel()
        {
            Model = new WpfApplication1.Model();
            Model.ObjectList = new List<string>();
            Model.ObjectList.Add("Aaaaa");
            Model.ObjectList.Add("Bbbbb");
            Model.ObjectList.Add("Ccccc");
            Model.Things = new List<Thing>();
            Model.Things.Add(new Thing() { ObjectText = "Aaaaa" });
        }
    }
    

    Behavior

    public class CellSelectedBehavior
    {
        public static bool GetIsCellRowSelected(DependencyObject obj) { return (bool)obj.GetValue(IsCellRowSelectedProperty); }
    
        public static void SetIsCellRowSelected(DependencyObject obj, bool value) { obj.SetValue(IsCellRowSelectedProperty, value); }
    
        public static readonly DependencyProperty IsCellRowSelectedProperty = DependencyProperty.RegisterAttached("IsCellRowSelected",
          typeof(bool), typeof(CellSelectedBehavior), new UIPropertyMetadata(false, OnIsCellRowSelected));
    
        static void OnIsCellRowSelected(DependencyObject depObj, DependencyPropertyChangedEventArgs e)
        {
            TextBox item = depObj as TextBox;
            if (item == null)
                return;
    
            if (e.NewValue is bool == false)
                return;
    
            if ((bool)e.NewValue)
                item.MouseDoubleClick += SelectRow;
            else
                item.MouseDoubleClick -= SelectRow;
        }
    
        static void SelectRow(object sender, EventArgs e)
        {
            TextBox box = sender as TextBox;
            var grid = box.FindAncestor<DataGrid>();
            grid.BeginEdit();
        }
    }
    

    Helper (to find DataGrid)

    public static class Helper
    {
        public static T FindAncestor<T>(this DependencyObject current) where T : DependencyObject
        {
            current = VisualTreeHelper.GetParent(current);
            while (current != null)
            {
                if (current is T)
                {
                    return (T)current;
                }
                current = VisualTreeHelper.GetParent(current);
            };
            return null;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want use BYTE_ORDER macro in my Xcode project but i can't because i
I want use Kendo ui window, but I can't see what the problem is.
I want to use hover function with live method but it is not working
i want to use title on text. is this possible to make title on
I want use many bitmap for my game canvas. I can't Recycle bitmaps, because
I want use 1000 separator(,) for numeric values. how can i format strings with
I want use only one decimal and only number in input type.so i am
I want use Mysql Migration Toolkit to migrate MS SQL to MySQL. I can't
I want use MVVM design pattern in WPF and Silverlight Application. Where can i
I want use html & css in form.text_area :text <%= sanitize @post.text , tags:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.