How to declare an empty string in Metro UI XAML

I am trying to write a simple replacement for a missing one in WinRT DataTriggers, something like:

<dt:DataTrigger Property="Message" Value=""> <dt:Setter TargetName="tbMessage" Property="Visibility" Value="Collapsed" /> </dt:DataTrigger> 

So, I have a DataTrigger class with Value set to XAML. I need to set the value to string.Empty. When I use "" (empty braces), the value is set to null, not string.Empty. I tried to define an empty string in the Resource:

 <x:String x:Key="EmptyString"></x:String> 

And use it like

 <dt:DataTrigger Property="Message" Value="{StaticResource EmptyString}"> <dt:Setter TargetName="tbMessage" Property="Visibility" Value="Collapsed" /> </dt:DataTrigger> 

The value is still set to zero. I also tried using the following code:

 xmlns:sys="using:System" ... <sys:String x:Key="EmptyString"></sys:String> 

This code throws a Windows.UI.Xaml.Markup.XamlParseException "Type Exception" exception occurred in mscorlib.dll but was not processed in the user code

WinRT Information: Type "String" not found. "

The approach using <x:Static Member="sys:String.Empty" /> cannot be used, because in WinRT x:Static missing.

Is it even possible to declare an empty string in WinRT XAML?

+4
source share
1 answer

try it

 <TextBlock Text="{x:Static System:String.Empty}" Name="emptyString"/> 
0
source

Source: https://habr.com/ru/post/1446007/


All Articles