TargetNullValue, wie Set-String aus dem Windows-Ressource [WPF]
-
25-09-2019 - |
Frage
Hallo, ich würde für die Bindung auf Text-Eigenschaft festgelegt Standardwert gefallen.
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 für TextBlock- diese Bindung:
<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>
ist Problem, wenn die Variable Info.Age null ist, ich wpf Fenster Eigenschaft Text Wert "constAge" nein "Alter". Prorties Text von String-Variable keinen Wert von String-Variable Wert Namen.
Lösung
TargetNullValue="{StaticResource constSex}"
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow