title: How to Bind IsSelected Property in DataTemplate of ListViewItem
body: <p>Well, I want to make the <code>ListViewItem</code> in UWP ,that'll be changing his view on selecting. So I need to change the     <code>Visibility</code>     property of some elements of <code>ListViewItem</code> on selecting. </p>
  
  <p>I found some way to do this with making custom Style of <code>ListViewItem</code> and Binding     <code>IsSelected</code>    property like this:</p>
  
  <pre><code>&lt;Style x:Key="VehicleListViewItemStyle" TargetType="ListViewItem" &gt;
              &lt;Setter Property="Template"&gt;
                  &lt;Setter.Value&gt;
                      &lt;ControlTemplate TargetType="ListViewItem"&gt;
                          &lt;Grid Background="Gray" Margin="1"&gt;
                              &lt;Border Margin="2" Padding="10" Background="Gray" &gt;
                                  &lt;StackPanel&gt;
                                      &lt;ContentPresenter x:Name="Presenter1" /&gt;
                                      &lt;StackPanel Orientation="Horizontal" Background="Transparent" Margin="-10,0,-9,-9" VerticalAlignment="Center" x:Name="infoPanel"
                                          Visibility="{Binding IsSelected, RelativeSource={RelativeSource Mode=TemplatedParent}, Converter={StaticResource BooleanToVisibilityConverter}}"&gt;
                                          &lt;TextBlock Text="{Binding  DeviceID}/&gt;                                                                            &lt;/StackPanel&gt;
                                  &lt;/StackPanel&gt;
                              &lt;/Border&gt;
                              &lt;Border BorderThickness="1" BorderBrush="Orange" Visibility="{Binding IsSelected, RelativeSource={RelativeSource Mode=TemplatedParent}, Converter={StaticResource BooleanToVisibilityConverter}}"/&gt;
                          &lt;/Grid&gt;
                      &lt;/ControlTemplate&gt;
                  &lt;/Setter.Value&gt;
              &lt;/Setter&gt;
          &lt;/Style&gt;  
  </code></pre>
  
  <p>Its working good, but with this way I cant bind the <code>DeviceID</code> text.</p>
  
  <p>Another one way is creating <code>DataTemplate</code> like this:</p>
  
  <pre><code>&lt;DataTemplate x:Key="monitoringListViewItem" x:Name="item"&gt;
              &lt;Grid Background="Gray" Margin="1" Width="300" &gt;
                  &lt;StackPanel&gt;
                      &lt;ContentPresenter x:Name="Presenter"/&gt;
                      &lt;StackPanel Orientation="Horizontal"&gt;
                          &lt;Image Source="/Assets/14th_crane_stop.png" Height="50" Width="50" Stretch="Uniform"/&gt;
                          &lt;StackPanel Orientation="Vertical" Margin="25,0,0,0 " 
                                      Visibility="{Binding IsSelected, RelativeSource={RelativeSource Mode=TemplatedParent}, Converter={StaticResource BooleanToVisibilityConverter}}"
                                      &gt;
                              &lt;TextBlock Text="{Binding DeviceID}" Style="{StaticResource VehicleTextStyle}"/&gt;
                              &lt;TextBlock Text="{Binding Mark}" Style="{StaticResource VehicleTextStyle}"/&gt;
                          &lt;/StackPanel&gt;
                      &lt;/StackPanel&gt;
                  &lt;/StackPanel &gt;
              &lt;/Grid&gt;
          &lt;/DataTemplate&gt;
  </code></pre>
  
  <p>Now I can bind the text correctly, but cant bind the <code>IsSelected</code> property. I've tried to do this with different Modes, but it still doesn't work because I cant use the <code>TemplatedParent</code>  key inside the DataTemplate.</p>
  
  <p>So I need some answers: </p>
  
  <p>-can I bind the text in first way and how can I do that?
  -how can I bind the <code>IsSelected</code> property in the second way?</p>