setting balloon tooltip for an image - silverlight

how to set balloon tooltip for an image in silverlight?

Use the ToolTipService like so:
<Image>
<ToolTipService.ToolTip>
<ToolTip>
<!-- Any XAML Content Here -->
</ToolTip>
</ToolTipService.ToolTip>
</Image>

Related

Set an attribute of a property element

I have a image that I want to have a larger preview using a tooltip.
<Image MaxWidth="585" Margin="2" Source="{Binding Preview, IsAsync=true}">
<Image.ToolTip MaxWidth="800"> <!-- Error: Attribute "MaxWidth" is not allowed in property element -->
<Image Source="{Binding Preview, IsAsync=true}" />
</Image.ToolTip>
</Image>
How do I change the MaxWidth property of the ToolTip? Second question: How can I use the parent Source value within the child binding?
The issue is the ToolTip property is of type object, so it does not have a MaxWidth property. Because the ToolTip can accept an arbitrary object, to set the MaxWidth you should put a ToolTip (or another WPF element) inside of the ToolTip property and set the MaxWidth on that.
Something like:
<Image MaxWidth="585" Margin="2" Source="{Binding Preview, IsAsync=true}">
<Image.ToolTip>
<ToolTip MaxWidth="1000" MaxHeight="600">
<Image Source="{Binding Preview, IsAsync=true}" />
</ToolTip>
</Image.ToolTip>
</Image>

Silverlight - add tooltip to a rotated textblock

I have a TextBlock which is rotated at 90 degrees in the Silverlight XAML:
<TextBlock Name="txbPW" Text="West">
<TextBlock.RenderTransform>
<RotateTransformAngle="90" />
</TextBlock.RenderTransform>
</TextBlock>
I want to add a tooltip (not rotated) to it. Any help?
What's your problem? Do you want to show the tooltip rotated too?? Or don't?? Or are you just asking to add a tooltip to a textblock???
If you only want to add a tooltip to a textblock you have to do something like this:
<TextBlock Name="txbPW" Text="West">
<TextBlock.RenderTransform>
<RotateTransformAngle="90" />
</TextBlock.RenderTransform>
<ToolTipService.ToolTip>
<ToolTip Content="ToolTip"></ToolTip>
</ToolTipService.ToolTip>
</TextBlock>
http://bouncetadiss.blogspot.com.es/2010/02/tooltip-for-textblock-in-silverlight.html

TextBox with background image and color

I have a TextBox control and I would like to be able to set a background image and a background color.
Currently I can set one, or the other but not both. When I try to set both simultaneously I receive a "The property 'Background' is set more than once" error.
Here is the code I used:
<TextBox Name="tbImageTextBox">
<TextBox.Background>
<ImageBrush ImageSource="/Resources/Images/image.png"
AlignmentX="Right" Stretch="None"/>
<SolidColorBrush>#FF8D8A8A</SolidColorBrush>
</TextBox.Background>
</TextBox>
I have also attempted to set the background color in the style for the TextBox and the image in the <TextBox.Background>, but the color is ignored.
Use the grid resource for background as needed. Same resource can be used for multiple textboxes.
<Grid>
<Grid.Resources>
<ImageBrush x:Key="img" ImageSource="Blue hills.jpg"></ImageBrush>
<SolidColorBrush x:Key="brownBrush" Color="Brown"></SolidColorBrush>
</Grid.Resources>
<TextBox x:Name="test" Background="{StaticResource img}" Width="100" Height="40" />
</Grid>
I ended up putting the TextBox into a grid with the Background color set and applying the background image to the TextBox itself as using VisualBrush and DrawingBrush stretched my image or only applied the background color to the image - not the rest of the TextBox.
You will need to combine the colour and the image in a single Brush instance, you could use a DrawingBrush or a VisualBrush containing an Image control with your image and the Background set to the colour for example.
You probably want either a VisualBrush or a DrawingBrush. More information on those can be found at MSDN here. Something like this might get you started:
<Rectangle Width="75" Height="75">
<Rectangle.Fill>
<VisualBrush TileMode="Tile">
<VisualBrush.Visual>
<Grid>
<Image BaseUri="somepic.png" />
<Rectangle Brush="FF8D8A8A" />
</Grid>
</VisualBrush.Visual>
</VisualBrush>
</Rectangle.Fill>
</Rectangle>

Set foreground colour of Image's ToolTip

How do you set the Foreground colour for a single Image's ToolTip? (There are multiple Image controls on the page but I want to have the style applied to just one)
Andrew
For the image that you want to set the foreground to, add the following xaml code:
<Image Name="image1" Source="Untitled.png">
<Image.ToolTip>
<ToolTip Foreground="Red">
<StackPanel>
<TextBlock FontWeight="Bold">Submit Request</TextBlock>
<TextBlock>Submits the request to the server.</TextBlock>
</StackPanel>
</ToolTip>
</Image.ToolTip>
</Image>
The Foreground="Red" sets the color of the foreground for that specific tool tip.
OUTPUT:
SOURCE: http://wpftutorial.net/ToolTip.html

How To Style Title Property Of Silverlight Childwindow

How can I set the ChildWindow Title content from a style?
Setting the content to text is straightforward:
Setter Property="Title" Value="My Title Text"
How can I put a StackPanel or Image in the Title from the Setter? I know I could extract the entire style for the control and modify the Chrome but I would like to avoid having all that XAML to wade through just to change a small part.
<basics:ChildWindow.Title>
<StackPanel>
<TextBlock Text="Moo Title"/>
<Rectangle Fill="DarkCyan" Height="25" Width="25"/>
</StackPanel>
</basics:ChildWindow.Title>
Why do you want to use a setter in the first place?

Resources