2010-12-09 3 views
0

Bonjour Je voudrais définir la valeur par défaut pour la liaison sur la propriété Text.TargetNullValue, comment définir la chaîne à partir de la ressource Windows [WPF]

En ressources veuves J'ai des valeurs de chaîne 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> 

Je cette liaison pour 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> 

problème est si Info.Age variable est nulle, je WPF Texte propriété de la fenêtre ont valeur "constAge" non "Age". Prorties Le texte a le nom de la valeur de la variable de chaîne aucune valeur de la variable de chaîne.

Répondre

1
TargetNullValue="{StaticResource constSex}" 
+0

Merci pour l'aide –

Questions connexes