I have a listbox which uses the following template to bind a list of clips. I would like to pull one of those clips at random and have it play. That is the easy part and is pretty straight forward. I would then like to make an associated image visible. I can’t seem to find out how to get the controls associated with the index in the listbox. Any ideas.
`
<StackPanel Margin="0,0,0,12" Width="420">
<Button Click="Button_Click" Background="{StaticResource PhoneAccentBrush}"
Height="90" Width="420" x:Name="btn">
<StackPanel Orientation="Horizontal" >
<Image x:Name="Selected" Width="75" Source="Images/Playing.png" Visibility="Collapsed" />
<TextBlock Text="{Binding Name}" TextWrapping="NoWrap" Width="330" VerticalAlignment="Center"
Style="{StaticResource PhoneTextLargeStyle}" />
</StackPanel>
</Button>
</StackPanel>
</DataTemplate>
`
This is a ListBox so have a list of objects bound to its ItemsSource. Add a new “NowPlaying” property to the class of these objects. Bind this property to the Visibility property of the “Selected” Image via a BoolToValueConverter
Now you just toggle that new property and need not delve in the Visual Tree to do what the binding system should be doing for you