Почему не работает DataContext WPf

Есть такая разметка окна

<Window x:Class="NET03._1.AddWindowSensor"
        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:NET03._1"
        mc:Ignorable="d"
        Title="AddWindowSensor" Height="300" Width="300">
    <Window.Resources>
        <ControlTemplate x:Key="ValidationFailed">
            <StackPanel Orientation="Horizontal">
                <Border BorderBrush="Violet" BorderThickness="2">
                    <AdornedElementPlaceholder />
                </Border>
                <TextBlock Foreground="Red" FontSize="26" FontWeight="Bold">!</TextBlock>
            </StackPanel>
        </ControlTemplate>
    </Window.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <ComboBox x:Name="SensorTypeComboBox" Grid.Row="0" Grid.Column="1" Height="20" Width="120" DataContext="{Binding Path=SensorType}" SelectedIndex="0" />
        <Label Grid.Row="0" Height="30" Content="Sensor Type" HorizontalContentAlignment="Center" />
        <Label Grid.Row="1" Grid.Column="0" Height="30" Content="Measuring Interval"
               HorizontalContentAlignment="Center" />
        <TextBox x:Name="MeasuringIntervalTextBox" Grid.Row="1" Grid.Column="1" Height="20" MaxLength ="10" Width="120" DataContext="{Binding Path=MeasuringInterval}" Validation.ErrorTemplate="{StaticResource ValidationFailed}"  >
            <TextBox.Text>
                <Binding Path="MeasuringInterval" >
                    <Binding.ValidationRules>
                        <ExceptionValidationRule />
                    </Binding.ValidationRules>
                </Binding>
            </TextBox.Text>
        </TextBox>
        <Button x:Name ="AddSensor" Content="Add Sensor" Width="100" Height ="20" Grid.Row="1" Grid.ColumnSpan="2" Margin="0,80,0,0"></Button>
    </Grid>
</Window>

И ее код

 public partial class AddWindowSensor : Window,IAddWindowSensorView
    {
        private int _measuringInterval = 3;
        public AddWindowSensor()
        {
            InitializeComponent();
            this.SensorTypeComboBox.ItemsSource = Enum.GetValues(typeof(SensorType));
            this.DataContext = _measuringInterval;
        
            
        }

        public SensorType SensorType { get; set; }

        public int MeasuringInterval
        {
            get => _measuringInterval;
            set
            {
                if (_measuringInterval == 0)
                {
                    throw new ArgumentOutOfRangeException("Can't be less or equal 0");
                }

                _measuringInterval = value;
            }
        }

        public void ShowMessageError(string message)
        {
            MessageBox.Show(message);
        }

        public event EventHandler<EventArgs> AddNewSensor;
    }

Я уже все перебробовал но ничего не работает ни к свойству ни к полю. Что я делаю не так?


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