Ejemplo n.º 1
0
        private void ClearContextMenu()
        {
            MessageBubble parent = this.FindParent <MessageBubble>();

            if (parent != null)
            {
                ContextMenu = parent.ContextMenu;
            }
            else if (ContextMenu != null)
            {
                ContextMenu.Items.Clear();
            }
        }
Ejemplo n.º 2
0
        private void sv_ScrollChanged(object sender, ScrollChangedEventArgs e)
        {
            bool enableShit = true;

            if (enableShit)
            {
                ScrollViewer sv               = sender as ScrollViewer;
                var          visibleItems     = new List <int>();
                Rect         svViewportBounds = new Rect(sv.HorizontalOffset, sv.VerticalOffset, sv.ViewportWidth, sv.ViewportHeight);

                for (int i = 0; i < Items.Count; ++i)
                {
                    ContentPresenter container = this.ItemContainerGenerator.ContainerFromIndex(i) as ContentPresenter;

                    if (container != null)
                    {
                        var             offset  = VisualTreeHelper.GetOffset(container);
                        var             bounds  = new Rect(offset.X, offset.Y, container.ActualWidth, container.ActualHeight);
                        ChatUserMessage message = container.Content as ChatUserMessage;

                        if (message != null)
                        {
                            MessageBubble messageBubble = VisualTreeHelper.GetChild(container, 0) as MessageBubble;

                            if (messageBubble != null)
                            {
                                if (svViewportBounds.IntersectsWith(bounds))
                                {
                                    ImageBehavior.SetIsInView(messageBubble, true);
                                }
                                else
                                {
                                    ImageBehavior.SetIsInView(messageBubble, false);
                                }
                            }
                        }
                    }
                }
            }
        }