自己挖了一個大坑,,,然後苦逼的在碼代碼重寫樣式! 廢物不多少 直接上代碼 先在前臺創建一個TextBox,然後各種附加的屬性加上去:如圖所示 效果圖: 樣式代碼: 本文原創出處:http://www.cnblogs.com/PettyHandSome/ 歡迎各位轉載,但是未經作者本人同意,轉載文章 ...
自己挖了一個大坑,,,然後苦逼的在碼代碼重寫樣式! 廢物不多少
直接上代碼
1 <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,然後各種附加的屬性加上去:如圖所示
1 <Popup Name="pop3" AllowsTransparency="True" StaysOpen="True" PopupAnimation="Fade" IsOpen="False" PlacementTarget="{Binding ElementName=account}" Placement="Right" > 2 <Label Style="{StaticResource tipLable}"> 3 <StackPanel Orientation="Horizontal"> 4 <Label Content="請輸入用戶名"/> 5 </StackPanel> 6 </Label> 7 </Popup>
效果圖:
樣式代碼:
1 <Style TargetType="Label" x:Key="tipLable"> 2 <Setter Property="Template"> 3 <Setter.Value> 4 <ControlTemplate TargetType="{x:Type Label}"> 5 <Grid> 6 <Border CornerRadius="4" BorderBrush="Black" BorderThickness="1" VerticalAlignment="Top" Margin="8.5,0,0,0" Background="Yellow" HorizontalAlignment="Left" Padding="5"> 7 <ContentPresenter /> 8 </Border> 9 <Canvas Width="10" Height="10" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,10,0,0" Background="Transparent"> 10 <Path Stroke="Black" StrokeThickness="0.5" Fill="Yellow"> 11 <Path.Data> 12 <PathGeometry Figures="M 10,0 L 10,0,0,5 L 0,5,10,10"/> 13 </Path.Data> 14 </Path> 15 </Canvas> 16 </Grid> 17 </ControlTemplate> 18 </Setter.Value> 19 </Setter> 20 </Style>
本文原創出處:http://www.cnblogs.com/PettyHandSome/
歡迎各位轉載,但是未經作者本人同意,轉載文章之後必須在文章頁面明顯位置給出作者和原文連接,否則保留追究法律責任的權利