Здравствуйте.
Написал вроде не хитрый код:
using LotteryBrusketta.Models;
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.Navigation;
using System.Windows.Shapes;
namespace LotteryBrusketta
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public int Num_4 { get; set; } = 0;
MediaPlayer player = new MediaPlayer();
Numbers? numbers;
public MainWindow()
{
InitializeComponent();
this.DataContext = new Numbers();
}
private void BatStartRand_Click(object sender, RoutedEventArgs e)
{
numbers.Num_4 = 2;
player.Open(new Uri(@"Resource\Sounds\fanfary_tush.mp3", UriKind.RelativeOrAbsolute));
player.Play();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LotteryBrusketta.Models
{
public class Numbers
{
public int Num_4 { get; set; }
}
}
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<TextBlock x:Name="TextNum" Grid.Row="1" VerticalAlignment="Center" Foreground="Black" HorizontalAlignment="Center" FontSize="100">
<Run FontFamily="Caveat" Foreground="Black" Text="{Binding Num_4}"></Run>
<Run FontFamily="Caveat" Foreground="#FF9A99" Text="0"></Run>
<Run FontFamily="Caveat" Foreground="#6898FF" Text="0"></Run>
<Run FontFamily="Caveat" Text="0"></Run>
</TextBlock>
<Button x:Name="BatStartRand" Grid.Row="2" Content="Start" Click="BatStartRand_Click"></Button>
</Grid>
Не в какую не могу сообразить почему не работает.
Научите пожалуйста, как правильно настроить Binding.
Спасибо.