Mąż Zuzanny Harmider Szczęście
Mąż Zuzanny Harmider Szczęście
CC#
Created by Mąż Zuzanny Harmider Szczęście on 1/24/2025 in #help
Issues with wpf binding
Hey guys, i'm having some issues with bindining a number Score to a 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 shows 10, but when i increment Score it doesn't update
46 replies
CC#
Created by Mąż Zuzanny Harmider Szczęście on 1/22/2025 in #help
✅ Issues with canvas
No description
4 replies
CC#
Created by Mąż Zuzanny Harmider Szczęście on 1/21/2025 in #help
✅ Issues with window resizing
Hello, I have this code:
public partial class MainWindow : Window
{
private int Seed;
double WorldHeight { get; set; }
double WorldWidth { get; set; }
public MainWindow()
{
InitializeComponent();
Seed = new Random().Next(1,1000);
GenerateWorld();

}
private void GenerateWorld()
{
WorldHeight = Math.Round(Height / Tile.Size);
WorldWidth = Math.Round(Width / Tile.Size);
Random random = new Random(Seed);
for(int i = 0; i < WorldHeight; i++)
{
for(int j = 0; j < WorldWidth; j++)
{
TileType type = new TileType[] { TileType.Stone, TileType.Grass }[random.Next(0, 2)];
Tile tile = new Tile(Convert.ToDouble(j),Convert.ToDouble(i),type);
Display.Children.Add(tile);
}
}
}
private void OnWindowResize(object sender, EventArgs e)
{
Display.Children.Clear();
GenerateWorld();
}
}
public partial class MainWindow : Window
{
private int Seed;
double WorldHeight { get; set; }
double WorldWidth { get; set; }
public MainWindow()
{
InitializeComponent();
Seed = new Random().Next(1,1000);
GenerateWorld();

}
private void GenerateWorld()
{
WorldHeight = Math.Round(Height / Tile.Size);
WorldWidth = Math.Round(Width / Tile.Size);
Random random = new Random(Seed);
for(int i = 0; i < WorldHeight; i++)
{
for(int j = 0; j < WorldWidth; j++)
{
TileType type = new TileType[] { TileType.Stone, TileType.Grass }[random.Next(0, 2)];
Tile tile = new Tile(Convert.ToDouble(j),Convert.ToDouble(i),type);
Display.Children.Add(tile);
}
}
}
private void OnWindowResize(object sender, EventArgs e)
{
Display.Children.Clear();
GenerateWorld();
}
}
My issue is that the OnWindowResize() is not triggered when fullsreening the app
7 replies
CC#
Created by Mąż Zuzanny Harmider Szczęście on 1/20/2025 in #help
✅ Listbox issue
hey, having issues with a listbox template:
<ListBox x:Name="PersonList" SelectionMode="Multiple">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Label Content="{Binding Name}"/>
<Label Content="{Binding Surname}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<ListBox x:Name="PersonList" SelectionMode="Multiple">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Label Content="{Binding Name}"/>
<Label Content="{Binding Surname}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
can you guys tell me what's wrong here?
public RemovePersonList(List<Person> personList)
{
InitializeComponent();
PersonList.ItemsSource = personList;
}
//How person class looks:
class Person{
public string Name;
public string Surname;
//...
}
public RemovePersonList(List<Person> personList)
{
InitializeComponent();
PersonList.ItemsSource = personList;
}
//How person class looks:
class Person{
public string Name;
public string Surname;
//...
}
The issue is that the items show up but they are empty
4 replies