2015年4月26日 星期日

WPF學習筆記 - 8 WPF ToolTip

可以在任何的Controls中使用,當鼠標移到控制項上就會出現提示訊息

ToolTip="你想提示的話"

比較特別的是,ToolTip不只可以放string type,而是可以放object type,
所以你可以在ToolTip做出豐富的效果

<Button>
                <Button.Content>
                    <Image Source="/WpfTutorialSamples;component/Images/folder.png" Width="16" Height="16" />
                </Button.Content>
                <Button.ToolTip>
                    <StackPanel>
                        <TextBlock FontWeight="Bold" FontSize="14" Margin="0,0,0,5">Open file</TextBlock>
                        <TextBlock>
                        Search your computer or local network
                        <LineBreak />
                        for a file and open it for editing.
                        </TextBlock>
                        <Border BorderBrush="Silver" BorderThickness="0,1,0,0" Margin="0,8" />
                        <WrapPanel>
                            <Image Source="/WpfTutorialSamples;component/Images/help.png" Margin="0,0,5,0" />
                            <TextBlock FontStyle="Italic">Press F1 for more help</TextBlock>
                        </WrapPanel>
                    </StackPanel>
                </Button.ToolTip>
</Button>

ToolTip就像root control一樣,可以讓我們在裡面加上許多的controls

其他屬性

ToolTipService.ShowDuration="5000" - 提示出現5秒
ToolTipService.ShowOnDisabled ="True" - 被disable的control也會出現提示


text render
TextOptions. TextFormattingMode
TextOptions. TextRenderingMode

從.NET 4.0之後,developer可以自行指定想要用怎樣的模式來顯示text,使用TextOptions

沒有留言:

張貼留言

[泰國] 芭達雅大城八日遊 Day7、8 - 瑪哈泰寺、Wat Ratchaburana、帕蒙空博碧寺、帕席桑碧寺、Hua Ro market、Chantharakasem National Museum、Amporn Department Store

第七天行程,早上吃飯店早餐,算不錯吃,只是有螞蟻,但吃完沒拉,所以應該還好 吃飽後飽嘟嘟車,一小時 200 泰銖,比自己叫還便宜,終於要來世界遺產之旅了 第一站:瑪哈泰寺,應該是大城最有名的景點了,入門票大人 120 ,小孩免費,其實不便宜 大城指標性景點...