W
W
wolfak2014-02-17 18:02:10
Programming
wolfak, 2014-02-17 18:02:10

How are XAML object property values ​​set?

Good evening.
I just can't understand how the properties of objects are set, for example, Foreground or Margin?
Code example:

public MainPage()
        {
            this.InitializeComponent();
            TextBlock story = new TextBlock();
            story.Text = "TestTestTest";
            story.FontSize = 22;
            story.Margin = "???";
            story.Foreground = "???";
            body.Children.Add(story);
        }

These methods cause an error:
textBlock.Foreground = new SolidColorBrush(Color.FromRgb(0, 0, 255));

или

textBlock.Foreground = Brushes.Blue;

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
Ilya, 2014-02-17
@wolfak

story.Margin = new Thickness(0,5,0,5);
story.Foreground = new SolidColorBrush(Colors.LimeGreen);

A
AlexP11223, 2014-02-17
@AlexP11223

What mistake? namespace not added or what?
All 3 methods mentioned in this thread work.

R
Roman, 2014-02-17
@WNeZRoS

using Windows.UI; // для Colors
using Windows.UI.Xaml.Media; // для SolidColorBrush

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question