TargetNullValue, como defina a String do Windows Resource [WPF
-
25-09-2019 - |
Pergunta
Olá, gostaria de definir o valor padrão para vincular a propriedade de texto.
Nas viúvas Recursos, tenho valores de string 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>
Eu tenho essa ligação para o 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>
O problema é que, se as informações variáveis. PRORTIES O texto tem o nome de valor da variável string, nenhum valor da variável string.
Solução
TargetNullValue="{StaticResource constSex}"
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow