產生無限數量的氣泡漂浮在窗口上,來回移動,相互碰撞,您還可以向氣泡添加一些文本提示,下面是錯新技術頻道小編帶給大家的WPF氣泡提示框的簡單制作,一起來看看吧!
具體操作內容如下:
直接上代碼
<TextBox Name="account" GotFocus="account_GotFocus" LostFocus="account_LostFocus" Style="{StaticResource LabelTextBox}" xl:ControlAttachProperty.Label="用戶名:" Foreground="Black" Margin="10,10,273,271" Width="Auto" />先在前臺創建一個TextBox,然后各種附加的屬性加上去:如圖所示

<Popup Name="pop3" AllowsTransparency="True" StaysOpen="True" PopupAnimation="Fade" IsOpen="False" PlacementTarget="{Binding ElementName=account}" Placement="Right" > <Label Style="{StaticResource tipLable}"> <StackPanel Orientation="Horizontal"> <Label Content="請輸入用戶名"/> </StackPanel> </Label> </Popup>效果圖:

樣式代碼:
<Style TargetType="Label" x:Key="tipLable"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Label}"> <Grid> <Border CornerRadius="4" BorderBrush="Black" BorderThickness="1" VerticalAlignment="Top" Margin="8.5,0,0,0" Background="Yellow" HorizontalAlignment="Left" Padding="5"> <ContentPresenter /> </Border> <Canvas Width="10" Height="10" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,10,0,0" Background="Transparent"> <Path Stroke="Black" StrokeThickness="0.5" Fill="Yellow"> <Path.Data> <PathGeometry Figures="M 10,0 L 10,0,0,5 L 0,5,10,10"/> </Path.Data> </Path> </Canvas> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style>以上就是錯新技術頻道小編為大家帶來的WPF氣泡提示框的簡單制作,希望對大家的學習有所幫助,也希望大家繼續支持錯新技術頻道!
新聞熱點
疑難解答
圖片精選