Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use the VisualTreeHelper and drill down to the control. This is not recommended though.<br> Better is to only bind to the properties of the controls in you datatemplate and then retrieve the values by getting the binded values. Technically in this case, if you would want to change the content of the radiobutton then you would need to change the item in the itemssource</p> <p>Can you explain what you are trying to archieve by getting the content of the radiobutton?</p> <p>Edit*<strong><em>*</em>**<em>*</em>**<em>*</em>**</strong></p> <pre><code> &lt;ListBox Name="listBoxDefaultAcc" HorizontalAlignment="Left" VerticalAlignment="Top" Width="450" Height="410"&gt; &lt;ListBox.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;StackPanel Orientation="Horizontal" Height="60" Width="450"&gt; &lt;RadioButton Content="{Binding Name}" IsChecked="{Binding Selected, Mode=TwoWay}" GroupName="defaultAcc" HorizontalAlignment="Left" VerticalAlignment="Center" Height="80" Width="450" /&gt; &lt;/StackPanel&gt; &lt;/DataTemplate&gt; &lt;/ListBox.ItemTemplate&gt; public partial class Home : Page { public Home() { InitializeComponent(); var items = new List&lt;SomeClass&gt;(); items.Add(new SomeClass() {Name = "a"}); items.Add(new SomeClass() {Name = "b"}); items.Add(new SomeClass() {Name = "c"}); listBoxDefaultAcc.ItemsSource = items; } // Executes when the user navigates to this page. protected override void OnNavigatedTo(NavigationEventArgs e) { } private void testButton_Click(object sender, RoutedEventArgs e) { var items = (List&lt;SomeClass&gt;)listBoxDefaultAcc.ItemsSource; var selectedItem = items.Where(x =&gt; x.Selected).FirstOrDefault(); } class SomeClass { public string Name { get; set; } public bool Selected { get; set; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload