Dannie
Dannie

Reputation: 11

How can I add value to existing textbox in xaml

I have the following TextBlock:

  <TextBlock VerticalAlignment="Vertical" Text="Name" />

This is the TextBlock for my button on which I want to display name and value.

I want to display text on the button as Name[some_value]. I'm getting this this some_value run-time from some function. How can I print the value here?

Upvotes: 0

Views: 1051

Answers (2)

Gul Ershad
Gul Ershad

Reputation: 1771

Go to ViewModel of that View:

private string _buttonValue;
public string ButtonValue{
get {return _buttonValue;}
}

Go to constructor and write down:

_buttonValue = "Name " + put_here_SomeValue_Runtime_Value;

Now, to to .xaml Bind like belw:

<TextBlock Text="{Binding ButtonValue, Mode=OneWay}"/>

Upvotes: 0

Thomas Bouman
Thomas Bouman

Reputation: 608

It seems like you're not yet familiar with Binding in XAML.

You can read, and see examples on MSDN here.

Upvotes: 1

Related Questions