© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•13mo ago•
45 replies
Mąż Zuzanny Harmider Szczęście

✅ Issues with wpf binding

Hey guys, i'm having some issues with bindining a number
Score
Score
to a
Label
Label
in wpf, here's my code:
    public partial class MainWindow : Window
    {
        public static int Score { get; set; } = 10;
        public static int Seed {  get; set; }
        double WorldHeight { get; set; }
        double WorldWidth { get; set; }

        public MainWindow()
        {
            InitializeComponent();
            Seed = new Random().Next(1,1000);
            Loaded+=(s,e)=>GenerateWorld();
            DataContext = this;
        }
      //....
     }
    public partial class MainWindow : Window
    {
        public static int Score { get; set; } = 10;
        public static int Seed {  get; set; }
        double WorldHeight { get; set; }
        double WorldWidth { get; set; }

        public MainWindow()
        {
            InitializeComponent();
            Seed = new Random().Next(1,1000);
            Loaded+=(s,e)=>GenerateWorld();
            DataContext = this;
        }
      //....
     }

    <Canvas x:Name="Display">
        <Label x:Name="ScoreDisplay" Content="{Binding Path=Score}" Panel.ZIndex="10" Canvas.Top="0" Canvas.Left="960" FontSize="24" FontWeight="Bold"/>
    </Canvas>
    <Canvas x:Name="Display">
        <Label x:Name="ScoreDisplay" Content="{Binding Path=Score}" Panel.ZIndex="10" Canvas.Top="0" Canvas.Left="960" FontSize="24" FontWeight="Bold"/>
    </Canvas>

At the beggining the
Label
Label
shows
10
10
, but when i increment
Score
Score
it doesn't update
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ Help with wpf binding issues
C#CC# / help
12mo ago
WPF binding
C#CC# / help
13mo ago
Wpf binding failures
C#CC# / help
15mo ago
❔ WPF data binding
C#CC# / help
3y ago