Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Silverlight TextBlock Visibility property inital value before binding is applied

I Have a TextBlock on Silverlight Page.

XAML

 <TextBlock Text="*"  x:Name="HasChangesTextBlock" Foreground="Red" FontSize="14" Visibility="{Binding Path=HasChanges, Converter={StaticResource BooleanToVisibilityConverter}}"
                           Margin="5,0,0,0">

 </TextBlock>

Page loading takes few moments. And before binding is applied I want TextBlock to be collapsed, but default value of Visibility Property is Visible.

Is there way to make TextBlock to be collapsed before binding is applied?

like image 648
terkri Avatar asked Dec 17 '09 11:12

terkri


1 Answers

I found the solution.

we should just add FallbackValue=Collapsed to the binding expression

That is a breaking change that was introduced in Silverlight 4.

XAML

   <TextBlock Text="*"  x:Name="HasPlayListChangesTextBlock" Foreground="Red" FontSize="14" 
                               Visibility="{Binding Path=HasChanges, Converter={StaticResource BooleanToVisibilityConverter},FallbackValue=Collapsed}">

   </TextBlock>
like image 196
terkri Avatar answered Nov 15 '22 10:11

terkri