Blendester
Blendester

Reputation: 1653

UWP How to bind to two values?

I have a DownloadModel which contains two properties. I want to show summary of those two properties in a single TextBlock

<TextBlock Text="{x:Bind DownloadModel.Part1.Progress, Mode=OneWay}"/>

Is there any way to pass Download.Part1.Progress and Download.Part2.Progress together then show summary of both in the TextBlock?

(If it's possible to do so with Binding instead of x:Bind that will be fine too) Thanks.

Upvotes: 3

Views: 2015

Answers (1)

mindOfAi
mindOfAi

Reputation: 4602

You can actually use Run inside a TextBlock. You can use it like this:

For example, I have these two strings:

    private string FirstText = "This is the first text.";
    private string SecondText = "This is the second text.";

I have this in my XAML:

    <TextBlock Foreground="Black">
        <Run Text="{x:Bind FirstText}"/>
        <Run Text="{x:Bind SecondText}"/>
    </TextBlock>

And This is how the app looks like:

enter image description here

Hope it helps!

Upvotes: 7

Related Questions