コード例 #1
0
        private PopupWindow CreateTweetTipWindow()
        {
            PopupWindow tipWindow = new PopupWindow()
            {
                Width = 400, ShowArrow = false, ShowCloseButton = false, Background = this.Background, TitleWrapping = TextWrapping.Wrap
            };

            tipWindow.Resources.Add("HyperlinkField", "authorUri");

            StackPanel tipPanel = new StackPanel()
            {
                Margin = new Thickness(2, 2, 2, 2), Orientation = Orientation.Horizontal
            };

            tipWindow.Content = tipPanel;

            Binding titleBinding = new Binding()
            {
                Path = new PropertyPath("[title]")
            };

            tipWindow.SetBinding(PopupWindow.TitleProperty, titleBinding);

            Image tipImage = new Image()
            {
                Stretch = System.Windows.Media.Stretch.Uniform, VerticalAlignment = System.Windows.VerticalAlignment.Top
            };
            Binding imgBinding = new Binding()
            {
                Path = new PropertyPath("[photoUrl]")
            };

            tipImage.ImageOpened += new EventHandler <RoutedEventArgs>(tipImage_ImageOpened);
            tipImage.SetBinding(Image.SourceProperty, imgBinding);
            tipPanel.Children.Add(tipImage);

            RichTextBox contentBox = new RichTextBox()
            {
                Width = 340, BorderThickness = new Thickness(0)
            };
            Binding contentBinding = new Binding()
            {
                Path = new PropertyPath("[content]")
            };

            contentBox.SetBinding(StackPanel.TagProperty, contentBinding);
            tipPanel.Children.Add(contentBox);

            return(tipWindow);
        }