1

私は、さまざまな色から選択できるコンボボックスを持つ c# の wpf プログラムを持っています。こんな感じです

? 文章

別のプログラムで特定のテキストの色を変更できるコンフィギュレーターを作成しています。したがって、ユーザーがプログラムを開いて説明テキストの色が気に入らない場合は、コンフィギュレーターを開いて色を変更できます。ユーザーがコンボボックスから色を選択すると、テキストの色が変わります。ユーザーがマウスを ? テキストの色が変更されたプログラムのイメージを示すイメージが表示されます。これまでのところ、プログラムの画像を表示することはできますが、その上にテキストを表示することはできません。これは私が今持っているものです:

        System.Windows.Controls.Image td = new System.Windows.Controls.Image();
        BitmapImage myBitmapImage = new BitmapImage();
        myBitmapImage.BeginInit();
        myBitmapImage.UriSource = new Uri(Directory.GetCurrentDirectory() + "/Homepage.jpg");
        myBitmapImage.DecodePixelWidth = 700;
        myBitmapImage.DecodePixelHeight = 590;
        myBitmapImage.EndInit();
        td.Source = myBitmapImage;

        ToolTipService.SetPlacement(image1, System.Windows.Controls.Primitives.PlacementMode.Left);
        ToolTipService.SetToolTip(image1, td);
        ToolTipService.SetShowDuration(image1, 999999999);

テキストを画像の上に表示するにはどうすればよいToolTipですか?

4

2 に答える 2

2

ToolTipService を使用すると、ツール ヒントを任意のコンテンツに設定できます。画像とテキストの両方を含むパネルとして設定します。次のコードはこれを実現します。

TextBlock textBlock = new TextBlock();
textBlock.Foreground = Brushes.White;
textBlock.HorizontalAlignment = HorizontalAlignment.Center;
textBlock.VerticalAlignment = VerticalAlignment.Center;
textBlock.Text = "Overlaying Image Text";

Grid toolTipPanel = new Grid();
toolTipPanel.Children.Add(td);
toolTipPanel.Children.Add(textBlock);

ToolTipService.SetToolTip(image1, toolTipPanel);
于 2009-07-22T18:49:46.387 に答える
0

装飾層を見てみてください。基本的に、装飾レイヤーを使用すると、下にあるコントロールのレイアウトに影響を与えずにアイテムを表示できます。

于 2009-07-22T17:54:45.047 に答える