Hi all :)
[__i am="" sorry="" for="" misspellings="" -="" english="" isn="t my 1st language><br mode="hold" /><br mode="hold" />I" m="" a="" student="" new="" to="" i="ve been trying for the last 24 hours to overcome this problem: <br mode="hold" /><br mode="hold" />Problem description: instade of adding 5 labels that represent scores of random diceThrow() by dragging the label to the Designer... <br mode="hold" />I want to create those 5 Labels - by code - creating an array of labels and generate them and present them during the program runnning time. << This is what I need<<<br mode="hold" /><br mode="hold" />I took the
"XMAL" "XAML" code and I am struggling with it" s="" translation="" into="" my="" code="" didn="t learn xmal, but only introduction to programing using C# and WPF].<br mode="hold" />I" using="" wpf="" application="" and="" grid.=""__]
This is the XMAL line I'm trying to replace by code:
// Label Height="28" HorizontalAlignment="Left" Margin="221,98,0,0" Name="lblScoreD6" VerticalAlignment="Top" Width="100" Content="0" /
// Grid.ColumnSpan="4" Grid.Column="1"
This is as far as I managed to go:
[my problem is ** I CAN'T SEE THE LABELS ONCE THE PROGRAM IS RUNNING **]
(mybe it's becouse I don't know how to translate this line into my code:
Grid.ColumnSpan="4" Grid.Column="1" from xmal to c# code)
Please advise..
Thx on advance!
Eyal David,
public MainWindow()
{
InitializeComponent();
Label[] scoresLabelArr = new Label[5];
int location = 98;
for (int i = 0; i < scoresLabelArr.Length; i++)
{
Label currentLabel = new Label();
scoresLabelArr[i] = (Label)currentLabel;
scoresLabelArr[i].Name = "lblScoreDice" + i;
scoresLabelArr[i].Height = 28;
scoresLabelArr[i].Width = 100;
scoresLabelArr[i].HorizontalAlignment = HorizontalAlignment.Left;
scoresLabelArr[i].VerticalAlignment = VerticalAlignment.Top;
scoresLabelArr[i].Content = "0";
scoresLabelArr[i].Margin = new Thickness(211, location, 0, 0);
scoresLabelArr[i].Foreground = Brushes.Black;
grid1.Children.Add(currentLabel);
location += 34;