نوشته شده توسط
Amir Oveisi
کد xaml ای که نوشتید برای textbox اینجا قرار بدید تا بررسی شه.
کد Xaml:
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
x:Class="TextBoxTest.MainWindow"
x:Name="Window"
Title="MainWindow"
Width="640" Height="480" Foreground="{x:Null}">
<Window.Resources>
<Style x:Key="TextBoxStyle1" TargetType="{x:Type TextBox}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBox}">
<Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal">
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(Rad ialGradientBrush.RadiusX)" Storyboard.TargetName="textBox">
<EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0.431"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Disabled"/>
<VisualState x:Name="ReadOnly"/>
<VisualState x:Name="MouseOver">
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(Rad ialGradientBrush.RadiusX)" Storyboard.TargetName="textBox">
<EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0.793"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<TextBox x:Name="textBox" TextWrapping="Wrap" Foreground="Black" FontSize="24" AcceptsReturn="True" TextAlignment="Left">
<TextBox.Background>
<RadialGradientBrush Center="0.488,0.502" GradientOrigin="0.488,0.502" RadiusX="0.427" RadiusY="1.074">
<GradientStop Color="#26FFFFFF" Offset="1"/>
<GradientStop Color="#E200FF04"/>
</RadialGradientBrush>
</TextBox.Background>
</TextBox>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
<Window.Background>
<ImageBrush ImageSource="986573_Abstract-green-picture_620.jpg.png"/>
</Window.Background>
<Grid x:Name="LayoutRoot">
<TextBox x:Name="Text1" Height="47" Margin="100,125,278,0" Style="{DynamicResource TextBoxStyle1}" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" TextAlignment="Right" Foreground="Black"/>
<Button Content="Button" HorizontalAlignment="Left" Height="50" Margin="126,0,0,158" VerticalAlignment="Bottom" Width="149" Click="Button_Click"/>
</Grid>
</Window>
کد C#:
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace TextBoxTest
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
this.InitializeComponent();
// Insert code required on object creation below this point.
}
private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
{
// TODO: Add event handler implementation here.
Text1.Text="Hello world!";
MessageBox.Show(Text1.Text);
}
}
}
عکس خروجی رو هم ضمیمه کردم.
ممنون