Ejemplo n.º 1
0
        //----------------------------------------------------------------------------------------------------------------------
        private void TcList_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            return;

            tcList.ApplyTemplate();
            DataTemplate     myDataTemplate   = tcList.ContentTemplate;
            ContentPresenter contentPresenter = FindVisualChild <ContentPresenter>(tcList);

            try
            {
                DataGrid dg = myDataTemplate.FindName("dbTracks", contentPresenter) as DataGrid;
                IPlayerActionQueriable playerAction = DataContext as IPlayerActionQueriable;
                if (dg != null && playerAction != null)
                {
                    int idx = playerAction.TrackByList(dg.DataContext);
                    if (idx >= 0)
                    {
                        dg.ScrollIntoView(dg.Items[idx]);
                        dg.SelectedIndex = idx;
                        //dg.SelectedItems.Clear();
                        //dg.SelectedItems.Add(item);
                    }
                }
            }
            catch
            {
            }
        }
Ejemplo n.º 2
0
        //-------------------------------------------------------------------------------------------------------------------
        private void ScrollIntoView()
        {
            tcList.ApplyTemplate();
            DataTemplate     myDataTemplate   = tcList.ContentTemplate;
            ContentPresenter contentPresenter = FindVisualChild <ContentPresenter>(tcList);

            try
            {
                DataGrid dg = myDataTemplate.FindName("dbTracks", contentPresenter) as DataGrid;
                IPlayerActionQueriable playerAction = DataContext as IPlayerActionQueriable;
                if (dg != null && playerAction != null)
                {
                    int idx = playerAction.TrackByList(dg.DataContext);
                    if (idx >= 0)
                    {
                        dg.ScrollIntoView(dg.Items[idx]);
                        dg.SelectedIndex = idx;
                        Keyboard.Focus(dg);
                        //                           ContentPresenter cp = dg.ItemContainerGenerator.ContainerFromItem(dg.Items[idx]) as ContentPresenter;
                        ////                           TextBox tb = FindVisualChild<TextBox>(cp);
                        //                           TextBlock tb = dg.ItemTemplate.FindName("tbFileName", cp) as TextBlock;
                        //                           if (tb != null)
                        //                           {
                        //                               // do something with tb
                        //                           }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }