title: How do I cast a dependency property in {x:bind}?
body: <p>The <a href="https://msdn.microsoft.com/en-us/library/windows/apps/xaml/mt204783" rel="nofollow">documentation</a> for <code>{X:bind}</code> mentions that casting in a property path is possible (the mention <code>{x:Bind obj.(TextBox.Text)}</code>) as example. I can't see how this should work in the following simple example. I tried various combinations of the type name in parens, but no success.</p>
  
  <p>A common use case would be a two-way binding for a combobox, here I would cast the <code>SelectedValue</code> property from the generic object type to a more specifc type.</p>
  
  <p>Example xaml page <em>MainPage.xaml</em>:</p>
  
  <pre><code>&lt;Page
      x:Class="XBindTest4.MainPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:local="using:XBindTest4"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      mc:Ignorable="d" &gt;
  
      &lt;StackPanel&gt;
          &lt;ComboBox ItemsSource="{x:Bind SampleList, Mode=OneWay}" 
                    SelectedValue="{x:Bind SampleData, Mode=TwoWay}"/&gt;
      &lt;/StackPanel&gt;
  
  &lt;/Page&gt;
  </code></pre>
  
  <p>Code behind <em>MainPage.xaml.cs</em>: </p>
  
  <pre><code>using System.Collections.ObjectModel;
  using Windows.UI.Xaml.Controls;
  
  namespace XBindTest4 {
  
      public class SampleClass {
      }
  
      public sealed partial class MainPage : Page {
  
          public ObservableCollection&lt;SampleClass&gt; SampleList = new ObservableCollection&lt;SampleClass&gt;(new[] {
              new SampleClass(),
              new SampleClass()
              });
  
          public SampleClass SampleData { get; set; }
  
          public MainPage() {
              this.InitializeComponent();
          }
      }
  }
  </code></pre>