title: Silverlight 4: how to switch control visibility
body: <p>I am using MVVM in my Silverlight app. When control visibility is need to be managed by data, I am connecting its 'Visibility' property to object's corresponding property:</p>
  
  <p>XAML:</p>
  
  <pre><code>&lt;TextBlock Text="Price" Visibility="{Binding PriceVisibility, Mode=OneWay}"/&gt;
  &lt;TextBox Text="{Binding TicketPrice, Mode=TwoWay}" Visibility="{Binding PriceVisibility, Mode=OneWay}"/&gt;
  </code></pre>
  
  <p>CodeBehind (C#):</p>
  
  <pre><code>public string PriceVisibility { get { return PriceVisible ? "Visible" : "Collapsed"; } }
  </code></pre>
  
  <p>But from my perspective, returning string representation of the Visibility property is not a best approach.</p>
  
  <p>Could you please advise if there are any better way?</p>
  
  <p>Thanks!</p>