Search code examples
c#.netwpfbindingmultibinding

Binding Two Property To ==> single Control


Suppose I have property

FIrstName and LastName

I need to bound it with single textbox.

So in just single textbox I can display both FirstName and LastName.

Then how could it be possible?


Solution

  • You can use multibinding to do that
    For OnWay Binding use this:

    <TextBox>
        <TextBox.Text>
            <MultiBinding StringFormat="{}{0} {1}" Mode="OneWay">
                <Binding Path="FirstName"/>
                <Binding Path="LastName"/>
            </MultiBinding>
        </TextBox.Text>
    </TextBox>
    

    For more information about MutiBinding Class look at here