2010-12-09 6 views
0

Hi Ich möchte den Standardwert für die Bindung auf Text-Eigenschaft festlegen.TargetNullValue, wie Set-String von Windows-Ressource [WPF]

In Witwen Ressourcen I const String-Werte haben:

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

Ich habe Bindung dies für 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> 

Problem ist, wenn die Variable Info.Age null ist, ich WPF-Fenster Eigenschaft Text haben Wert "constAge" nein "Alter". Prorties text hat value name der string-variablen kein wert der string-variablen.

Antwort

1
TargetNullValue="{StaticResource constSex}" 
+0

Vielen Dank fpr Hilfe –