开发者

how to make Balloon ToolTip in SilverlightApplication?

开发者 https://www.devze.com 2023-01-29 23:01 出处:网络
i\'m trying to make a balloon tooltip with close button in a silverlight web 开发者_运维百科application.... how can i do it?There\'s an MSDN blog entry on how to customize the tooltip. Basically you:

i'm trying to make a balloon tooltip with close button in a silverlight web 开发者_运维百科application.... how can i do it?


There's an MSDN blog entry on how to customize the tooltip. Basically you:

set the ToolTip's Template property to a fancy new Template which is defined in the page resources.

The code is this:

<UserControl.Resources>
    <ControlTemplate x:Key="ToolTipTemplate">
        <Border>
            <Grid>
                -- other stuff --
                <ContentPresenter Grid.Column="1"
                                    Content="{TemplateBinding Content}"
                                    ContentTemplate="{TemplateBinding ContentTemplate}"
                                    Margin="{TemplateBinding Padding}" 
                                    VerticalAlignment="Center"/>
            </Grid>
        </Border>
    </ControlTemplate>
</UserControl.Resources>

and then to use it:

    <TextBox Height="20" Width="100">
        <ToolTipService.ToolTip>
            <ToolTip Template="{StaticResource ToolTipTemplate}">
                <ToolTip.Content>
                    <TextBlock 
                       Text="This is a longer string of text." 
                       FontFamily="Georgia" FontSize="14" TextWrapping="Wrap"/>
                </ToolTip.Content>
            </ToolTip>
        </ToolTipService.ToolTip>
    </TextBox>

(code copied from the blog entry).


I wrote an article recently, that shows a balloon tool tip, which can be placed over any FrameworkElement in Silverlight. Also the alignment can be changed using the Alignment property in Balloon.

Notification Control in Silverlight

0

精彩评论

暂无评论...
验证码 换一张
取 消