开发者

WPF Compact this XAML which assigns static string to binding

开发者 https://www.devze.com 2023-01-07 02:58 出处:网络
There may not be any practical use of what I want to do, but just to satisfy my curiosity can we comp开发者_如何学Goact the 2nd binding in the following XAML into 1 line

There may not be any practical use of what I want to do, but just to satisfy my curiosity can we comp开发者_如何学Goact the 2nd binding in the following XAML into 1 line

<TextBlock>
    <TextBlock.Text>
        <MultiBinding Converter="{StaticResource MyConverter}">
            <Binding Source="{StaticResource One}"></Binding>
            <Binding>
                <Binding.Source>
                    <sys:String>2</sys:String>
                </Binding.Source>
            </Binding>
        </MultiBinding>
    </TextBlock.Text>
</TextBlock>

StaticResource One gives me "1" and MyConverter just concatenates all values it gets. What I am looking for is some way to express the 2nd binding in a compact format like the 1st binding.


I'm assuming there's some reason you don't want to define a second static resource called Two and then use the same syntax as with One...

You should be able to:

<Binding Source="2"/>

Since Source is just an Object, this should assign the string "2" to the Source. Haven't checked though as I'm on linux at the moment.

0

精彩评论

暂无评论...
验证码 换一张
取 消