0

こんにちは私はTextプロパティのバインディングのデフォルト値を設定したいと思います。

未亡人のリソースには、const文字列値があります。

<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>

私はTextBlockにこのバインディングを持っています:

        <TextBlock Style="{StaticResource InfosStyle2}" Width="160" Grid.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>

問題は、変数Info.Ageがnullの場合、ウィンドウプロパティTextの値が「constAge」で「Age」ではないことです。プロパティテキストには、文字列変数の値名があり、文字列変数の値はありません。

4

1 に答える 1

1
TargetNullValue="{StaticResource constSex}"
于 2010-12-09T18:34:19.243 に答える