Не работает Binding WPF

У меня есть команда LogInCommand:

private void OnLogInCommandExecuted(object obj)
{
    Application.Current.Shutdown();
}

private bool CanLogInCommandExecute(object obj) => LoginEntered == "";

LoginEntered привязано:

<TextBox Style="{StaticResource LogEnterStyle}" Text="{Binding LoginEntered, Mode = OneWayToSource, UpdateSourceTrigger = PropertyChanged}"/>

И всё работает, если не использовать стиль. Если использовать, то кнопка всегда активна:

<Style 
TargetType="{x:Type TextBox}"
x:Key="LogEnterStyle">
<Setter Property="Template">
    <Setter.Value>
        <ControlTemplate TargetType="{x:Type TextBox}">
            <Grid>

                <TextBox 
                    BorderThickness="0"
                    Text="{TemplateBinding Text}"
                    Background="Transparent" 
                    FontSize="30" 
                    x:Name="LoginBox"
                    Foreground="Black" 
                    HorizontalAlignment="Stretch"
                    TextAlignment="Center"/>

                <TextBlock 
                    Margin="1"
                    Text="Логин"
                    VerticalAlignment="Center"
                    HorizontalAlignment="Center"
                    Background="Transparent"
                    Foreground="#909996"
                    IsHitTestVisible="False"
                    FontSize="30">

                    <TextBlock.Style>
                        <Style TargetType="{x:Type TextBlock}">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding Text, ElementName = LoginBox}" Value="">
                                    <Setter Property="Visibility" Value="Visible"/>
                                </DataTrigger>
                            </Style.Triggers>
                            <Setter Property="Visibility" Value="Hidden"/>
                        </Style>
                    </TextBlock.Style>
                </TextBlock>    
                         
            </Grid>
        </ControlTemplate>
    </Setter.Value>
</Setter>

Как это можно исправить? Заранее спасибо


Ответы (0 шт):