开发者

TargetNullValue, how set string from windows resource[WPF]

开发者 https://www.devze.com 2023-01-30 07:12 出处:网络
Hi I would like set default value for binding on Text property. In widows resources I have const string values:

Hi I would like set default value for binding on Text property.

In widows resources I have const string values:

<Window.Resources>
    <sys:String x:Key="constSex">Pohlavie</sys:String>
    <sys:String x:Key="constAge">Age</sys:String>
    <sys:String x:Key="constRegion">Region</sys:String>
    <sys:String x:Key="constCity">Mesto</sys:String>
    <sys:String x:Key="constPhotoAlbums">Fotoalbumov: 0</sys:String>
    <sys:String x:Key="constVideoAlbums">Videoalbumov :0</sys:String>
</Window.Resources>

I have this binding for TextBlock:

        <TextBlock Style="{StaticResource InfosStyle2}" Width="160" G开发者_开发百科rid.Row="0" HorizontalAlignment="Left">
            <TextBlock.Text>
                <MultiBinding StringFormat="{}{0}, {1}">
                    <Binding Path="Info.Sex" TargetNullValue="constSex" Mode="OneWay" UpdateSourceTrigger="PropertyChanged" Converter="{StaticResource sexConvertor}" />
                    <Binding Path="Info.Age" TargetNullValue="constAge" Mode="OneWay" UpdateSourceTrigger="PropertyChanged"/>                            
                </MultiBinding>
            </TextBlock.Text>
        </TextBlock>

Problem is if variable Info.Age is null, I wpf window property Text have value "constAge" no "Age". Prorties Text have value name of string variable no value of string variable.


TargetNullValue="{StaticResource constSex}"
0

精彩评论

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