Exemplo n.º 1
0
        public static void OnAutoScrollToEndChanged(DependencyObject s, DependencyPropertyChangedEventArgs e)
        {
            var itemsControl = s as ItemsControl;

            if (itemsControl != null)
            {
                var itemsControlItems = itemsControl.Items;
                var data = itemsControlItems.SourceCollection as INotifyCollectionChanged;

                var scrollToEndHandler = new NotifyCollectionChangedEventHandler(
                    (s1, e1) =>
                {
                    if (itemsControl.Items.Count > 0)
                    {
                        ExecuteOnUIThread.Invoke(() =>
                        {
                            ScrollViewer scrollViewer = VisualTree.GetDescendantByType <ScrollViewer>(itemsControl);
                            scrollViewer?.ScrollToEnd();
                        });
                    }
                });

                if (data != null)
                {
                    if ((bool)e.NewValue)
                    {
                        data.CollectionChanged += scrollToEndHandler;
                    }
                    else
                    {
                        data.CollectionChanged -= scrollToEndHandler;
                    }
                }
            }
        }
Exemplo n.º 2
0
 private void ScrollToLast(DataGrid grid)
 {
     if (grid.Items.Count > 0 && VisualTreeHelper.GetChildrenCount(grid) != 0)
     {
         Decorator border = VisualTreeHelper.GetChild(grid, 0) as Decorator;
         if (border != null)
         {
             ScrollViewer scroll = border.Child as ScrollViewer;
             if (scroll != null)
             {
                 scroll.ScrollToEnd();
             }
         }
     }
 }
 private void Collection_ListChanged(object sender, ListChangedEventArgs e)
 {
     if (dgv_DBtable.Items.Count > 0)
     {
         border = VisualTreeHelper.GetChild(dgv_DBtable, 0) as Decorator;
         if (border != null)
         {
             scroll = border.Child as ScrollViewer;
             if (scroll != null)
             {
                 scroll.ScrollToEnd();
             }
         }
     }
 }
Exemplo n.º 4
0
        /// <summary>
        ///     添加消息
        /// </summary>
        /// <param name="message">消息内容</param>
        /// <param name="color">文字颜色</param>
        /// <param name="fontSize">字体大小</param>
        /// <param name="fontFamily">字体</param>
        /// <param name="isNeedLineBreak">是否需要换行</param>
        public void AddMessage(string message, Color color, double fontSize, FontFamily fontFamily,
                               bool isNeedLineBreak = true)
        {
            string lastMessage;
            var    run        = CreateRun(out lastMessage, message, color, fontSize, fontFamily, isNeedLineBreak);
            var    newMessage = isNeedLineBreak ? message : lastMessage + message;

            Paragraph.Inlines.Add(run);
            if (ScrollViewer != null)
            {
                ScrollViewer.ScrollToEnd();
            }
            ExcuteAnimation(run);
            RaiseEvent(newMessage, lastMessage);
        }
Exemplo n.º 5
0
        //This method Updates the scrollable chatbox and scrolls to the bottom.
        private async void UpdateScrollBox()
        {
            var newMessageList = new List <MessageData>();

            newMessageList = MatchmakerAPI_Client.DeserializeMessageData(await MatchmakerAPI_Client.GetMessageData(chatID));
            if (newMessageList.Count() != messageList.Count())
            {
                newMessageList = newMessageList.OrderBy(msg => msg.timestamp).ToList();
                messageList    = newMessageList;
                MessageList.Children.Clear();
                FillScrollBox();
                ScrollViewer.ScrollToEnd();
                MatchmakerAPI_Client.SetToRead(chatID, userSender);
            }
        }
Exemplo n.º 6
0
            //removes extra text (prevent memory leak)
            //and scrolls view to bottom (like a console)
            private void UpdateView()
            {
                int    len                  = view.Text.Length;
                double scrollHeight         = scroll.ViewportHeight;
                double viewHeight           = view.ActualHeight;
                int    totalLines           = CountLines(view.Text);
                int    lineHeight           = (int)viewHeight / totalLines;
                int    possibleVisibleLines = (int)(scrollHeight / lineHeight);

                if (viewHeight > scrollHeight)
                {
                    view.Text = GetFinalLines(view.Text, totalLines, Math.Min(totalLines, possibleVisibleLines));
                }
                scroll.ScrollToEnd();
            }
Exemplo n.º 7
0
        private void OnEntriesChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (m_scrollviewer == null)
            {
                // Find the ScrollViewer below our DockPanel
                foreach (var c in m_dockpanel.Children.OfType <ItemsControl>())
                {
                    if (c.Template.FindName("m_scrollviewer", c) is ScrollViewer sv)
                    {
                        m_scrollviewer = sv;
                    }
                }
            }

            m_scrollviewer?.ScrollToEnd();
        }
Exemplo n.º 8
0
 private void Thumb_LeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     if (_isResizeEffect)
     {
         var ele = sender as FrameworkElement;
         _isResizeEffect = false;
         if (ele != null)
         {
             ele.ReleaseMouseCapture();
         }
         if (ScrollViewer != null)
         {
             ScrollViewer.ScrollToEnd();
         }
     }
 }
Exemplo n.º 9
0
        private async void SendMessage(string text, bool closing = false)
        {
            try
            {
                if (!Client.Connected)
                {
                    await Client.ConnectAsync("eubfwcf.cloudapp.net", 700);
                }
                var imageUrl = Kernel.ProfilePicture;
                if (string.IsNullOrEmpty(imageUrl))
                {
                    imageUrl = "http://i.epvpimg.com/2Wrnc.png";
                }
                var entry2 = new ChatEntryJson(imageUrl, text, Kernel.CustomName);

                var json   = JsonConvert.SerializeObject(entry2);
                var buffer = Encoding.UTF8.GetBytes(json);

                var entryJson = await JsonConvert.DeserializeObjectAsync <ChatEntryJson>(json);

                var entry = new ChatEntry(entryJson.ImageUrl, entryJson.Text, entryJson.Username, true);
                await Stream.WriteAsync(buffer, 0, buffer.Length);

                await Stream.FlushAsync();

                var panel = new StackPanel {
                    MaxWidth = Kernel.UI.Width, Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Right
                };
                var block2 = new TextBlock {
                    TextWrapping = TextWrapping.Wrap, Text = "  ", VerticalAlignment = VerticalAlignment.Center
                };

                panel.Children.Add(entry.Text);
                panel.Children.Add(block2);
                panel.Children.Add(entry.Img);
                ChatBox.Children.Add(panel);
                ScrollViewer.ScrollToEnd();
            }
            catch
            {
                if (closing)
                {
                    return;
                }
                MessageBox.Show("Failed to send the message. Server did not respond", "Fail");
            }
        }
        public void Log(MessageLevel level, string message, params object[] args)
        {
            if (!_uiDispatcher.CheckAccess())
            {
                _uiDispatcher.Invoke(
                    new Action <MessageLevel, string, object[]>(Log),
                    level,
                    message,
                    args);
                return;
            }

            var line = string.Format(message, args) + Environment.NewLine;

            _textBox.Text += line;
            _scrollViewer.ScrollToEnd();
        }
Exemplo n.º 11
0
        private void Scroll_ScrollChanged(ScrollViewer sender, ScrollChangedEventArgs e)
        {
            bool shouldAutoScrollToBottom = sender.Tag == null || (bool)sender.Tag;

            // set autoscroll mode when user scrolls, and store it in the ScrollViewer's Tag.
            if (e.ExtentHeightChange == 0)
            {
                shouldAutoScrollToBottom = sender.VerticalOffset == sender.ScrollableHeight;
                sender.Tag = shouldAutoScrollToBottom;
            }

            // autoscroll to bottom
            if (shouldAutoScrollToBottom && e.ExtentHeightChange != 0)
            {
                sender.ScrollToEnd();
            }
        }
Exemplo n.º 12
0
        public static void AddNewMessage(string msg)
        {
            consoleListMessage.Add(msg);

            if (consoleElement != null)
            {
                if (consoleElement.Dispatcher.CheckAccess())
                {
                    consoleElement.BBCode += "> " + msg.Replace("\n", "") + "\n";
                    consoleElementScroll.ScrollToEnd();
                }
                else
                {
                    consoleElement.Dispatcher.Invoke((Action)(() => { consoleElement.BBCode += "> " + msg.Replace("\n", "") + "\n";  consoleElementScroll.ScrollToEnd(); }));
                }
            }
        }
Exemplo n.º 13
0
        public TechnologyProblemInfo(DataRowView techProblemView, int curWorkerId)
        {
            InitializeComponent();
            App.BaseClass.GetTechnologyProblemClass(ref _tpr);
            _curWorkerId = curWorkerId;

            Height = 450;
            Width  = 600;
            RequestInfoGrid.Visibility = Visibility.Visible;
            RequestInfoGrid.IsEnabled  = true;
            _workerNameConverter       = new IdToNameConverter();
            _techProblemView           = techProblemView;
            DataContext = techProblemView;
            SetRowsHeight();
            FillBlank();
            ScrollViewer.ScrollToEnd();
        }
Exemplo n.º 14
0
        private void AddRuleButton_OnClick(object sender, RoutedEventArgs e)
        {
            ScrollViewer.ScrollToEnd();
            var r = new RuleSetter();

            r.xButton_Clicked += (o, args) => {
                var animation = CustomAnimation.GetLeavingScreenAnimation(r.ActualHeight, 0);
                animation.Completed += (sender1, eventArgs) => { innerSp.Children.Remove(o as RuleSetter); };
                r.BeginAnimation(HeightProperty, animation);
            };
            r.Loaded +=
                (o, args) => {
                r.BeginAnimation(HeightProperty,
                                 CustomAnimation.GetEnteringScreenAnimation(0, r.ActualHeight));
            };
            innerSp.Children.Add(r);
        }
Exemplo n.º 15
0
        public static void AutoScrollPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
        {
            ScrollViewer scrollViewer = obj as ScrollViewer;

            if (scrollViewer != null && (bool)args.NewValue)
            {
                scrollViewer.ScrollChanged += ScrollViewer_ScrollChanged;
                scrollViewer.ScrollToEnd();
            }
            else
            {
                if (scrollViewer != null)
                {
                    scrollViewer.ScrollChanged -= ScrollViewer_ScrollChanged;
                }
            }
        }
Exemplo n.º 16
0
 ///<summary>当加载模板后</summary>
 public override void OnApplyTemplate()
 {
     try
     {
         m_ScrollViewer = GetTemplateChild("ScrollViewer") as ScrollViewer;
         if (m_ScrollViewer != null)
         {
             m_ScrollViewer.ScrollToEnd();
         }
         var button = GetTemplateChild("BtnClear") as Button;
         if (button != null)
         {
             button.Click += OnButtonClearClick;
         }
     }
     catch { }
 }
Exemplo n.º 17
0
        public ShellView()
        {
            InitializeComponent();

            DispatcherTimer timer = new DispatcherTimer();

            timer.Interval = new TimeSpan(0, 0, 2);
            timer.Tick    += ((sender, e) =>
            {
                ScrollBox.Height += 10;

                if (ScrollViewer.VerticalOffset == ScrollViewer.ScrollableHeight)
                {
                    ScrollViewer.ScrollToEnd();
                }
            });
            timer.Start();
        }
Exemplo n.º 18
0
        protected override void OnItemsChanged(NotifyCollectionChangedEventArgs e)
        {
            base.OnItemsChanged(e);

            if (e.Action == NotifyCollectionChangedAction.Add)
            {
                // An item was added to the ListBox.
                if (IsAutoScrollEnabled && VisualTreeHelper.GetChild(this, 0) is Decorator border)
                {
                    // Scroll to the bottom of the ListBox. If user is currently clicking the scrollbar, then do nothing.
                    ScrollViewer scroll = border.Child as ScrollViewer;
                    if (!scroll.IsMouseCaptureWithin)
                    {
                        scroll?.ScrollToEnd();
                    }
                }
            }
        }
Exemplo n.º 19
0
        private static void ScrollToEnd()
        {
            ScrollViewer scroll = Instance.console.Template.FindName("scroll", Instance.console) as ScrollViewer;

            if (scroll is null)
            {
                return;
            }

            double ScrollableSize = scroll.ViewportHeight;
            double ScrollPosition = scroll.VerticalOffset;
            double ExtentHeight   = scroll.ExtentHeight;

            if (ScrollableSize + ScrollPosition == ExtentHeight || ExtentHeight < ScrollableSize)
            {
                scroll.ScrollToEnd();
            }
        }
Exemplo n.º 20
0
        protected override void OnRender(DrawingContext drawingContext)
        {
            if (_adornerLayer != null && _autoScrollAdorner != null && VisualTreeHelper.GetChild(this, 0) is Decorator border)
            {
                ScrollViewer scroll = border.Child as ScrollViewer;
                if (scroll.ComputedVerticalScrollBarVisibility != Visibility.Visible)
                {
                    IsAutoScrollEnabled = true;
                    _adornerLayer.Remove(_autoScrollAdorner);
                }

                if (IsAutoScrollEnabled && !scroll.IsMouseCaptureWithin)
                {
                    scroll?.ScrollToEnd();
                }
            }
            base.OnRender(drawingContext);
        }
        public MainWindow()
        {
            InitializeComponent();

            DispatcherTimer timer = new DispatcherTimer {
                Interval = new TimeSpan(0, 0, 2)
            };

            timer.Tick += (sender, e) =>
            {
                ListViewContent.Height += 10;

                if (Math.Abs(ScrollViewer.VerticalOffset - ScrollViewer.ScrollableHeight) < 2)
                {
                    ScrollViewer.ScrollToEnd();
                }
            };
            timer.Start();
        }
Exemplo n.º 22
0
        //displays rich text in the main output window
        private void appendRuns(params Run [] runs)
        {
            //create a new "paragraph" element, vertically separating this bunch of runs from the previous bunch
            Paragraph newParagraph = new Paragraph();

            //fill it with the provided runs
            newParagraph.Inlines.AddRange(runs);

            //add it to the document in the output box
            this.outputBox.Document.Blocks.Add(newParagraph);

            //automatically scroll to the bottom
            ScrollViewer descendantScrollViewer = findScrollViewerDescendant(this.outputBox);

            if (descendantScrollViewer != null)
            {
                descendantScrollViewer.ScrollToEnd();
            }
        }
Exemplo n.º 23
0
 /// <summary>
 /// 変換状態変更イベント
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public void ConvertStateChanged(object sender, ConvertStateChangedEventArgs e)
 {
     if (Dispatcher.CheckAccess() == false)
     {
         Dispatcher.Invoke((Action)(() =>
         {
             ConvertStateChanged(sender, e);
         }));
         return;
     }
     // 進捗率以外のログ内容をウインドウに表示する
     if (e.FileProgress == -1)
     {
         LogListBox.Items.Add(e.LogData);
         if (logScroll != null)
         {
             logScroll.ScrollToEnd();
         }
     }
 }
Exemplo n.º 24
0
        private void ScrollViewer_ScrollChanged(Object sender, ScrollChangedEventArgs e)
        {
            ScrollViewer sv = sender as ScrollViewer;

            if (e.ExtentHeightChange == 0)
            {
                if (sv.VerticalOffset == sv.ScrollableHeight)
                {
                    AutoScroll = true;
                }
                else
                {
                    AutoScroll = false;
                }
            }

            if (AutoScroll && e.ExtentHeightChange != 0)
            {
                sv.ScrollToEnd();
            }
        }
Exemplo n.º 25
0
        private void OnEntriesChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (m_scrollviewer == null)
            {
                // Find the ScrollViewer below our DockPanel
                foreach (var child in m_dockpanel.Children)
                {
                    ItemsControl c = child as ItemsControl;
                    if (c != null)
                    {
                        object o = c.Template.FindName("m_scrollviewer", c);
                        if (o is ScrollViewer)
                        {
                            m_scrollviewer = o as ScrollViewer;
                        }
                    }
                }
            }

            m_scrollviewer?.ScrollToEnd();
        }
Exemplo n.º 26
0
        private async void CommandBinding_Executed_SendMessage(object sender, ExecutedRoutedEventArgs e)
        {
            Mensaje m = new Mensaje("Persona", MensajeTextBox.Text);

            mensajes.Add(m);
            MensajeTextBox.Text = "";

            string EndPoint = Properties.Settings.Default.EndPoint;
            string Key      = Properties.Settings.Default.Key;
            string Id       = Properties.Settings.Default.Id;

            QnAMakerRuntimeClient cliente = new QnAMakerRuntimeClient(new EndpointKeyServiceClientCredentials(Key))
            {
                RuntimeEndpoint = EndPoint
            };

            Mensaje mensajeRobot = new Mensaje("Robot", "Pensando...");

            mensajes.Add(mensajeRobot);
            disponible = false;
            string respuesta = "";

            try
            {
                string pregunta = m.Contenido;
                QnASearchResultList response = await cliente.Runtime.GenerateAnswerAsync(Id, new QueryDTO { Question = pregunta });

                respuesta = response.Answers[0].Answer;
            }
            catch (Exception)
            {
                respuesta = "Estoy ocupado ahora mismo";
            }

            mensajes.Remove(mensajeRobot);
            mensajeRobot.Contenido = respuesta;
            mensajes.Add(mensajeRobot);
            disponible = true;
            ScrollViewer.ScrollToEnd();
        }
Exemplo n.º 27
0
        public void LoadOrder(Order order, bool ScrollToEnd = false, int ScrollToIndex = -1)
        {
            if (MainScreen.ItemsInCart == null)
            {
                MainScreen.ItemsInCart = new ObservableCollection <ItemInCartModel>();
            }
            else
            {
                MainScreen.ItemsInCart.Clear();
            }

            foreach (var item in order.Cart)
            {
                AddItemToGuiCart(item);
            }

            MainScreen.Total = order.Total;
            MainScreen.Count = order.Cart.Count;

            //var point = item.TranslatePoint(new Point() - (Vector)e.GetPosition(sv), ip);
            //sv.ScrollToVerticalOffset(point.Y + (item.ActualHeight / 2));


            if (null != m_CartScroller)
            {
                if (ScrollToEnd)
                {
                    m_CartScroller.ScrollToEnd();
                }
                else if (ScrollToIndex != -1)
                {
                    ContentPresenter itemcontainer = ((ItemsControl)m_CartScroller.Content).ItemContainerGenerator.ContainerFromIndex(ScrollToIndex) as ContentPresenter;
                    if (itemcontainer != null)
                    {
                        itemcontainer.BringIntoView();
                    }
                }
            }
        }
        private static void AlwaysScrollToEndChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            ScrollViewer scroll = sender as ScrollViewer;

            if (scroll != null)
            {
                bool alwaysScrollToEnd = (e.NewValue != null) && (bool)e.NewValue;
                if (alwaysScrollToEnd)
                {
                    scroll.ScrollToEnd();
                    scroll.ScrollChanged += ScrollChanged;
                }
                else
                {
                    scroll.ScrollChanged -= ScrollChanged;
                }
            }
            else
            {
                throw new InvalidOperationException("The attached AlwaysScrollToEnd property can only be applied to ScrollViewer instances.");
            }
        }
Exemplo n.º 29
0
        /// <summary>
        /// 双击定位到某个未读消息会话
        /// </summary>
        private void JumpChatItem(object obj)
        {
            var chatVMList = this.ChatListVM.Items.ToList();

            if (chatVMList.Count == 0)
            {
                clickCount = 0;
                return;
            }
            var v = chatVMList.Where(m => m.UnReadCount > 0 && !m.Chat.Chat.IsNotDisturb).Select((chatVM, index) => new { index, chatVM }).OrderByDescending(n => n.chatVM.Chat.LastMsg.SendTime).ToList();

            if (v.Count == 0)
            {
                v = chatVMList.Where(m => m.UnReadCount > 0 && m.Chat.Chat.IsNotDisturb).Select((chatVM, index) => new { index, chatVM }).OrderByDescending(n => n.chatVM.Chat.LastMsg.SendTime).ToList();
                if (v.Count == 0)
                {
                    return;
                }
            }

            if (clickCount > v.Count - 1)
            {
                clickCount = 0;
            }
            var chatItem = v[clickCount].chatVM;
            var objView  = AppData.MainMV.ChatListVM.View as ChatListView;

            objView.list.Dispatcher.InvokeAsync(() =>
            {
                objView.list.UpdateLayout();
                Decorator decorator       = (Decorator)VisualTreeHelper.GetChild(objView.list, 0);
                ScrollViewer scrollViewer = (ScrollViewer)decorator.Child;
                scrollViewer.ScrollToEnd();
                objView.list.ScrollIntoView(chatItem);
            });
            clickCount++;
            //AppData.MainMV.ChatListVM.SelectedItem = chatItem;
            //AppData.MainMV.ChatListVM.IsChecked = true;
        }
Exemplo n.º 30
0
        public static void OnAutoScrollToEndChanged(DependencyObject s, DependencyPropertyChangedEventArgs e)
        {
            var listBox = s as ListBox;

            if (listBox != null)
            {
                var listBoxItems = listBox.Items;
                var data         = listBoxItems.SourceCollection as INotifyCollectionChanged;

                var scrollToEndHandler = new NotifyCollectionChangedEventHandler(
                    (s1, e1) =>
                {
                    if (listBox.Items.Count > 0)
                    {
                        //object lastItem = listBox.Items[listBox.Items.Count - 1];
                        //listBoxItems.MoveCurrentTo(lastItem);
                        //listBox.ScrollIntoView(lastItem);
                        ExecuteOnUIThread.Invoke(() =>
                        {
                            ScrollViewer scrollViewer = VisualTree.GetDescendantByType <ScrollViewer>(listBox);
                            scrollViewer?.ScrollToEnd();
                        });
                    }
                });

                if (data != null)
                {
                    if ((bool)e.NewValue)
                    {
                        data.CollectionChanged += scrollToEndHandler;
                    }
                    else
                    {
                        data.CollectionChanged -= scrollToEndHandler;
                    }
                }
            }
        }
Exemplo n.º 31
0
        public void TestScrolling()
        {
            const float elementWidth = 100;
            const float elementHeight = 200;
            const float elementDepth = 300;

            var rand = new Random();
            var scrollViewer = new ScrollViewer { ScrollMode = ScrollingMode.HorizontalVertical, Width = elementWidth, Height = elementHeight, Depth = elementDepth };
            scrollViewer.Measure(Vector3.Zero);
            scrollViewer.Arrange(Vector3.Zero, false);

            // tests that no crashes happen with no content
            scrollViewer.ScrollTo(rand.NextVector3());
            Assert.AreEqual(Vector3.Zero, ScrollPosition);
            scrollViewer.ScrollOf(rand.NextVector3());
            Assert.AreEqual(Vector3.Zero, ScrollPosition);
            scrollViewer.ScrollToBeginning(Orientation.Horizontal);
            Assert.AreEqual(Vector3.Zero, ScrollPosition);
            scrollViewer.ScrollToBeginning(Orientation.InDepth);
            Assert.AreEqual(Vector3.Zero, ScrollPosition);
            scrollViewer.ScrollToEnd(Orientation.Horizontal);
            Assert.AreEqual(Vector3.Zero, ScrollPosition);
            scrollViewer.ScrollToEnd(Orientation.InDepth);
            Assert.AreEqual(Vector3.Zero, ScrollPosition);

            // tests with an arranged element
            const float contentWidth = 1000;
            const float contentHeight = 2000;
            const float contentDepth = 3000;
            var content = new ContentDecorator { Width = contentWidth, Height = contentHeight, Depth = contentDepth };
            scrollViewer.Content = content;
            scrollViewer.Measure(Vector3.Zero);
            scrollViewer.Arrange(Vector3.Zero, false);

            var scrollValue = new Vector3(123, 456, 789);
            scrollViewer.ScrollTo(scrollValue);
            Assert.AreEqual(new Vector3(scrollValue.X, scrollValue.Y, 0), scrollViewer.ScrollPosition);

            scrollViewer.ScrollToEnd(Orientation.Horizontal);
            Assert.AreEqual(new Vector3(contentWidth - elementWidth, scrollValue.Y, 0), scrollViewer.ScrollPosition);
            scrollViewer.ScrollToEnd(Orientation.Vertical);
            Assert.AreEqual(new Vector3(contentWidth - elementWidth, contentHeight - elementHeight, 0), scrollViewer.ScrollPosition);
            scrollViewer.ScrollToEnd(Orientation.InDepth);
            Assert.AreEqual(new Vector3(contentWidth - elementWidth, contentHeight - elementHeight, 0), scrollViewer.ScrollPosition);

            scrollViewer.ScrollToBeginning(Orientation.Horizontal);
            Assert.AreEqual(new Vector3(0, contentHeight - elementHeight, 0), scrollViewer.ScrollPosition);
            scrollViewer.ScrollToBeginning(Orientation.Vertical);
            Assert.AreEqual(new Vector3(0, 0, 0), scrollViewer.ScrollPosition);
            scrollViewer.ScrollToBeginning(Orientation.InDepth);
            Assert.AreEqual(new Vector3(0, 0, 0), scrollViewer.ScrollPosition);

            scrollViewer.ScrollOf(scrollValue);
            Assert.AreEqual(new Vector3(scrollValue.X, scrollValue.Y, 0), scrollViewer.ScrollPosition);

            // tests with an not arranged element
            content.InvalidateArrange();
            scrollViewer.ScrollTo(scrollValue);
            scrollViewer.Arrange(Vector3.Zero, false);
            Assert.AreEqual(new Vector3(scrollValue.X, scrollValue.Y, 0), scrollViewer.ScrollPosition);
            content.InvalidateArrange();
            scrollViewer.ScrollOf(2*scrollValue);
            scrollViewer.ScrollTo(scrollValue);
            scrollViewer.Arrange(Vector3.Zero, false);
            Assert.AreEqual(new Vector3(scrollValue.X, scrollValue.Y, 0), scrollViewer.ScrollPosition);

            content.InvalidateArrange();
            scrollViewer.ScrollToEnd(Orientation.Horizontal);
            scrollViewer.ScrollToEnd(Orientation.Vertical);
            scrollViewer.ScrollToEnd(Orientation.InDepth);
            scrollViewer.Arrange(Vector3.Zero, false);
            Assert.AreEqual(new Vector3(contentWidth - elementWidth, contentHeight - elementHeight, 0), scrollViewer.ScrollPosition);

            content.InvalidateArrange();
            scrollViewer.ScrollToBeginning(Orientation.Horizontal);
            scrollViewer.ScrollToBeginning(Orientation.Vertical);
            scrollViewer.ScrollToBeginning(Orientation.InDepth);
            scrollViewer.Arrange(Vector3.Zero, false);
            Assert.AreEqual(new Vector3(0, 0, 0), scrollViewer.ScrollPosition);

            content.InvalidateArrange();
            scrollViewer.ScrollOf(scrollValue);
            scrollViewer.Arrange(Vector3.Zero, false);
            Assert.AreEqual(new Vector3(scrollValue.X, scrollValue.Y, 0), scrollViewer.ScrollPosition);
            content.InvalidateArrange();
            scrollViewer.ScrollToBeginning(Orientation.Horizontal);
            scrollViewer.ScrollToBeginning(Orientation.Vertical);
            scrollViewer.ScrollToBeginning(Orientation.InDepth);
            scrollViewer.ScrollOf(scrollValue);
            scrollViewer.ScrollOf(scrollValue);
            scrollViewer.Arrange(Vector3.Zero, false);
            Assert.AreEqual(new Vector3(2*scrollValue.X, 2*scrollValue.Y, 0), scrollViewer.ScrollPosition);
        }