. . .
xaml , .
<StackPanel Name="myStack" Orientation="Horizontal"></StackPanel>
, ,
Image coolPic = new Image() {
Name="pic",
Source = new BitmapImage(new Uri("pack://application:,,,/images/cool.png")),
Stretch = Stretch.None
};
TextBlock text = new TextBlock() {
Name = "myText",
Text = "This is my cool Pic"
};
myStack.Children.Add(coolPic);
myStack.Children.Add(text);
, , .
, , .
, .
, , ,
((TextBlock)FindName("myText")).Text = "my other cool pic";
, , ?
Object reference not set to an instance of an object.
Drats, .
RegisterName(text.Name, text);
, . , . , .
Image coolPic = new Image() {
Name="pic",
Source = new BitmapImage(new Uri("pack://application:,,,/images/cool.png")),
Stretch = Stretch.None
};
RegisterName(coolPic.Name, coolPic);
TextBlock text = new TextBlock() {
Name = "myText",
Text = "This is my cool Pic"
};
RegisterName(text.Name, text);
myStack.Children.Add(coolPic);
myStack.Children.Add(text);