Hi,
I want following behaviour in XamComboEditor: when I do the mouse left click, it should select the text displayed in the combo box. I have tried to use GotMouseCapture event and comboEditor.Focus() but it is not working. Below is the parts of the code:
Xaml:
<ig:XamComboEditorName="xamSearchBox" VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Standard" IsEditable="True" DropDownButtonDisplayMode="Focused"AllowDropDownResizing="True" GotMouseCapture="xamSearchBox_GotMouseCapture">
C#:
private void xamSearchBox_GotMouseCapture(object sender, System.Windows.Input.MouseEventArgs e) { xamSearchBox.Focus(); }
Hello,
Thank you for your post.
I have been looking into it. I have created a small sample application and it seem the default behavior of XamComboEditor is to get focus and select the text when click on it with mouse left button. I could not managed to reproduce the behavior that you have described. If you are not able to reproduce the issue with the attached sample application, would you please modify it with the functionality, that you are using, so it reproduces the issue. This way I would be able to further investigate this for you and provide you with more detailed information on this matter. I created a short video to show you how the application work on my, please let me know if I am missing something from your scenario.
Looking forward to hearing from you.
Thank you for your response, Zhivko. I could reproduce the issue with minor changes. Note that I am using Infragistics.Controls.Editors.XamComboEditor whereas you were using Infragistics.Windows.Editors.XamComboEditor. This is the code after my changes:
MainWindow.xaml:
<Window xmlns:igWPF="http://schemas.infragistics.com/xaml" x:Class="XamComboEditorTest.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Grid> <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" > <igWPF:XamComboEditor Name="xce" HorizontalAlignment="Center" VerticalAlignment="Center" Width="80" Height="40" IsEditable="True" VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Standard" DropDownButtonDisplayMode="Focused" ItemsSource="{Binding}"> </igWPF:XamComboEditor>
<igWPF:XamComboEditor Name="xce2" HorizontalAlignment="Center" VerticalAlignment="Center" Width="80" Height="40" IsEditable="True" VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Standard" DropDownButtonDisplayMode="Focused" ItemsSource="{Binding}"> </igWPF:XamComboEditor> </StackPanel> </Grid></Window>
MainWindow.xaml.cs:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Imaging;using System.Windows.Navigation;using System.Windows.Shapes;using System.ComponentModel;
namespace XamComboEditorTest{ /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> ///
public class Account { public string Name{get;set;}
public int Number{get;set;} }
public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); BindingList<Account> data = new BindingList<Account>();
for (int i = 0; i < 10; i++) { Account acct = new Account(); acct.Name = "Item " + i; acct.Number = i; data.Add(acct); }
//xce.DataContext = data; xce2.DataContext = data;
xce.ItemsSource = data; xce.SelectedValuePath = "Name"; TextSearch.SetTextPath(xce, "Name"); } }}
Thank, Zhivko. This works.
Thank you for your feedback.
I have been looking into your code snippet and it seems that currently the XamComboEditor you are using does not support built-in the functionality that you are looking for. What I can suggest in order to be able to achieve your requirement is to handle the GotFocus event of XamComboEditor and by using our Utilities class you can get the SpecializedTextBox element from the visual tree. That element displays the SelectedItem’s text in the XamComboEditor. Then you can call its SelectAll method and the text will be selected when the XamComboEditor gets focus. I have created a sample project in order to show you how you can implement this approach.
Please see the attached project and feel free to let me know if it helps you.