This is a migrated thread and some comments may be shown as answers.

Floating RadPaneGroup with RadGridView is stealing focus

1 Answer 44 Views
Docking
This is a migrated thread and some comments may be shown as answers.
Ulrich
Top achievements
Rank 1
Ulrich asked on 21 Aug 2012, 09:12 AM
Hello,

In a RadPaneGroup with a RadGridView we are showing some detials of a SQL search. In the background is a ViewModel and one of the property contains the resultrecords as array. Each new search request will create a new array of records and through a binding it changes the ItemsSource property of RadGridView. 


new Version 2012.2.725.40: the focus will jump into the RadGridView when RadPaneGroup is floating
old Version 2012.1.215.40: its all ok, the Fosuce stay in e.g. TextBox

a SampleApp below

<Window x:Class="RadGridViewFocusStealing.MainWindow"
        xmlns:RadGridViewFocusStealing="clr-namespace:RadGridViewFocusStealing" Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="50" />
            <RowDefinition Height="29" />
            <RowDefinition Height="259*" />
        </Grid.RowDefinitions>
        <Grid.DataContext>
            <RadGridViewFocusStealing:GridDataContextViewModel/>
        </Grid.DataContext>
        <TextBlock  Grid.Row="0" Text="Make the RadPaneGroup as floating. Select a record inside of the grid, than add some new records while typing in the TextBox below. You will see the focus will lost. If the RadPaneGroup is docked its all fine." TextWrapping="Wrap" />
        <telerik:RadWatermarkTextBox  Grid.Row="1" Text="{Binding Path=DoSomethingOnChange, UpdateSourceTrigger=Explicit}" KeyUp="TextBox_KeyUp" Margin="2" >
            <telerik:RadWatermarkTextBox.WatermarkContent>
                <TextBlock Text="Just type any text and press ↵ Enter to apply" Foreground="Gray"/>
            </telerik:RadWatermarkTextBox.WatermarkContent>
        </telerik:RadWatermarkTextBox>
        <telerik:RadDocking  Grid.Row="2">
            <telerik:RadDocking.Items>
                <telerik:RadSplitContainer x:Name="radSplitContainer" >
                    <telerik:RadSplitContainer.Items>
 
                        <telerik:RadPaneGroup >
                            <telerik:RadPaneGroup.Items>
                                <telerik:RadPane>
                                    <telerik:RadGridView
                                                 AutoGenerateColumns="False"
                                                 ItemsSource="{Binding Path=DataItems}" ShowGroupPanel="False">
                                        <telerik:RadGridView.Columns>
                                            <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=Property1}"/>
                                        </telerik:RadGridView.Columns>
                                    </telerik:RadGridView>
                                </telerik:RadPane>
                            </telerik:RadPaneGroup.Items>
                        </telerik:RadPaneGroup>
 
                    </telerik:RadSplitContainer.Items>
                </telerik:RadSplitContainer>
            </telerik:RadDocking.Items>
        </telerik:RadDocking>
    </Grid>
</Window>



using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using Telerik.Windows.Controls.Docking;
 
namespace RadGridViewFocusStealing
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            radSplitContainer.InitialPosition = DockState.FloatingDockable;
        }
 
        private void TextBox_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
        {
            if (e.Key == Key.Enter && e.KeyboardDevice.Modifiers == ModifierKeys.None)
            {
                var b = ((TextBox)sender).GetBindingExpression(TextBox.TextProperty);
                if (b != null)
                    b.UpdateSource();
            }
        }
    }
 
    public class GridDataContextViewModel : INotifyPropertyChanged
    {
        private IEnumerable<GridDataItem> _dataItems;
 
        public GridDataContextViewModel()
        {
            _dataItems = new GridDataItem[] { new GridDataItem() { Property1 = "Foo" }, new GridDataItem() { Property1 = "Baa" } };
        }
 
        private string _doSomethingOnChange;
 
        public string DoSomethingOnChange
        {
            get { return _doSomethingOnChange; }
            set
            {
                _doSomethingOnChange = value;
                OnNotifyPropertyChanged("DoSomethingOnChange");
 
                // As simulation, creating a new data array (e.g. a result of a SQLQuery as array) for GridView.ItemsSource
                DataItems = _dataItems.Union(new GridDataItem[] { new GridDataItem { Property1 = value } }).ToArray();
            }
        }
 
        public IEnumerable<GridDataItem> DataItems
        {
            get { return _dataItems; }
            private set
            {
                if (_dataItems != value)
                {
                    _dataItems = value;
                    OnNotifyPropertyChanged("DataItems");
                }
            }
        }
 
        private void OnNotifyPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
 
        public event PropertyChangedEventHandler PropertyChanged;
    }
 
    public class GridDataItem
    {
        public string Property1 { get; set; }
    }
}


1 Answer, 1 is accepted

Sort by
0
Ulrich
Top achievements
Rank 1
answered on 21 Aug 2012, 12:54 PM
With version 02259RadControls_for_WPF_2012_2_0820_DEV_hotfix (internal-build) it seems its fixed
Tags
Docking
Asked by
Ulrich
Top achievements
Rank 1
Answers by
Ulrich
Top achievements
Rank 1
Share this question
or