TextBox,passwordBox和Button不起作用

时间:2019-06-06 10:46:46

标签: c# wpf

我是c#的新手。我在wpf中创建了一个简单的登录页面。TextBox,passwordBox和Button不接受任何输入。我需要在PasswordBox中使用透明文本“ PassWord”。并且我还尝试了一些动画和绑定。

请尝试在您的系统中编译代码,以更好地理解我的问题。

有人可以帮我解决代码中的错误吗?

预先感谢

这是我尝试过的。

<Window x:Class="WpfApp1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        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"
        xmlns:local="clr-namespace:WpfApp1"
        mc:Ignorable="d"
        Background="#FFDDE9F7"
        Title="MainWindow" Height="710" Width="660">
    <Window.Resources>
        <Style x:Key="ChangeNextButtonColor" TargetType="Button">
            <Setter Property="Background" Value="CadetBlue"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Border Background="{TemplateBinding Background}">
                            <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Background" Value="Gray"/>
                    <Trigger.EnterActions>
                        <BeginStoryboard>
                            <Storyboard>
                                <ThicknessAnimation Duration="0:0:0.5" To="3" Storyboard.TargetProperty="BorderThickness" AutoReverse="True"/>
                                <DoubleAnimation Duration="0:0:0.4" To="46" Storyboard.TargetProperty="Height" AutoReverse="True"/>
                                <DoubleAnimation Duration="0:0:0.4" To="75" Storyboard.TargetProperty="Width" AutoReverse="True"/>
                            </Storyboard>
                        </BeginStoryboard>
                    </Trigger.EnterActions>
                </Trigger>
            </Style.Triggers>
        </Style>
    </Window.Resources>

    <Grid Margin="0,0,1,0">
        <Border BorderBrush="White" BorderThickness="1" HorizontalAlignment="Left" Height="642" Margin="22,21,0,0" VerticalAlignment="Top" Width="607" Background="White" CornerRadius="10" RenderTransformOrigin="0.5,0.5" >
            <Border BorderBrush="BurlyWood" BorderThickness="8" Margin="0,50,0,-2" CornerRadius="0,0,5,5" Background="BurlyWood" >
                <Grid>
                    <Border  BorderThickness="1" HorizontalAlignment="Left" Height="428" Margin="147,66,0,0" VerticalAlignment="Top" Width="316" RenderTransformOrigin="0.5,0.5" CornerRadius="13" Background="White" >
                        <Grid>
                            <Label Content="Sign Up" HorizontalAlignment="Left" VerticalAlignment="Top" FontWeight="Bold" FontSize="36" Foreground="BurlyWood" Height="92" Width="201" Margin="81,45,0,0"/>
                            <TextBox  Text="UserName" Background="Transparent" HorizontalAlignment="Left" Height="40" Margin="32,187,0,0" TextWrapping="Wrap"  VerticalAlignment="Top" Width="255" BorderBrush="Transparent" FontWeight="Bold" FontSize="20" Foreground="LightGray" />
                            <Rectangle HorizontalAlignment="Stretch" Fill="BurlyWood" Margin="32,226,29,198"/>
                            <PasswordBox HorizontalAlignment="Left" Height="40" Margin="32,251,0,0" VerticalAlignment="Top" Width="255" BorderBrush="Transparent" />
                            <Rectangle HorizontalAlignment="Stretch" Fill="BurlyWood" Margin="32,289,29,135"/>
                            <!--<Border BorderBrush="Transparent" BorderThickness="1" HorizontalAlignment="Left" Height="44" Margin="80,338,0,0" VerticalAlignment="Top" Width="165" Background="CadetBlue" CornerRadius="8" />-->
                            <Button Content="Next" HorizontalAlignment="Left" Margin="85,339,0,0" VerticalAlignment="Top" Width="155" Height="42" FontWeight="Bold" FontSize="24" Style="{StaticResource ChangeNextButtonColor}" Foreground="White" />
                        </Grid>
                    </Border>
                    <Image Source="D:\Users\Nivr\Downloads\fasetto-word-69f144a73638b5c789d8df155cd023a6ad68f5e7\Source\Fasetto.Word\Images\Backgrounds\emoji-background.png" Canvas.Left="-4" Canvas.Top="9" Width="603" Margin="-6,-12,-8,-5"/>
                    <Label Content="Haffun" Canvas.Left="255" Canvas.Top="193" RenderTransformOrigin="0.485,0.647" Height="36" Width="119" FontWeight="Bold" FontFamily="Tempus Sans ITC" FontSize="24" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#FFB9B0B0" Margin="250,183,220,357"/>
                    <Label Content="I already have an account " FontWeight="Bold" FontSize="20" RenderTransformOrigin="-0.069,0.29" Canvas.Left="171" Canvas.Top="502" Foreground="White" Margin="180,501,158,0" />
                </Grid>
            </Border>
        </Border>
        <Label Content="ABCD" HorizontalAlignment="Left" Margin="270,24,0,0" VerticalAlignment="Top" FontFamily="Pristina" FontWeight="Bold" FontSize="36"  />
    </Grid>
</Window>

0 个答案:

没有答案