I would like to display my score point in a textbox, even if the textbox.Text get the value, in GUI i can't see my score.
<UserControl x:Class="WpfCyberPunk.UserControls.UserControlPlaying"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WpfCyberPunk.UserControls"
mc:Ignorable="d"
d:DesignHeight="350" Width="Auto" d:DataContext="{d:DesignData }">
<Grid Name="PlayingGrid" Margin="0,0,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid Row="0" HorizontalAlignment="Left">
<StackPanel Name="SkPn_Score" Orientation="Horizontal">
<TextBlock HorizontalAlignment="Left" Margin="10,1,0,0" TextWrapping="Wrap" Text="Point de départ" VerticalAlignment="Center" Height="25" Width="100"/>
<TextBox x:Name = "tBx_StartPt" Text="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=ScoreText,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged }" TextChanged="TBx_StartPt_OnTextChanged" FontSize="10" HorizontalAlignment="Left" Margin="10,1,0,0" TextWrapping="Wrap" VerticalAlignment="Center" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Height="25" Width="50"/>
</StackPanel>
</Grid>
IN cs, I have
public partial class UserControlPlaying : UserControl
{
private string _score;
private int _point;
//public event DependencyProperty PropertyChanged;
public string Score
{
get => _score;
set
{
_score = value;
SetValue(ValueProperty, _score);
}
}
public static readonly DependencyProperty ValueProperty =
DependencyProperty.Register("Score", typeof(string), ownerType: typeof(UserControlPlaying), new PropertyMetadata(""));
And in my class, i have made an event to see, the new value
private void TBx_StartPt_OnTextChanged(object sender, TextChangedEventArgs e)
{
string newScore = tBx_StartPt.Text;
}
In debug, newScore get the new value.
I don't understand, anything does not display in GUI. Thank you for your help.