mscommunity.net

Interactive mscommunity.net online activities
Signed in as anonymous | Edit Profile | Sign out | Help
in Search

Weblog :: Boris Ševo

Sporadic posts about my interests, e.g. software development (mostly .NET), technology in general and some occasional rant.

WPF trick #3 - MultiBinding and StringFormat

One of the new features in .NET Framework 3.5 SP1 is StringFormat support within {{Binding}} expressions to enable easy formatting to bound values.
So, if some TextBlock control need to be bound to some object's properties (let's call them Max and Min) and the value of the TextBlock's Text property need to be in [Min - Max] format you can then write something like this:

    <TextBlock>
    <TextBlock.Text>
        <MultiBinding StringFormat="[{0} - {1}]">
            <Binding Path="Min"></Binding>
                <Binding Path="Max"></Binding>
            </MultiBinding>
        </TextBlock.Text>
     </TextBlock>
Published sij 20 2009, 02:17 by boris.sevo
Filed under:

Comments

 

anonymous said:

Thanks ! Exactly what I was trying to achieve

svibanj 25, 2009 5:29
 

anonymous said:

Thank You!!!! very very Thanks~!!

ožujak 4, 2010 2:51

Leave a Comment

(required) 
(optional)
(required) 
Submit
Powered by Community Server (Commercial Edition), by Telligent Systems