I am building a WP 8.1 Silverlight application.
I have an ObservableCollection
of row names that is set to ItemsSource
for a ListBox
. What are the names of the buttons in the ListBox
. Then I want to extract the buttons from the ListBox
, but the return value is of type string
.
Xaml code:
<ListBox x:Name="Game_ScrollViewer_online" Margin="41,104,128,6" SelectedValuePath="Current_game_button"> <ListBox.ItemTemplate> <DataTemplate> <Button x:Name="Current_game_button" Content="{Binding}" HorizontalAlignment="Center" Height="80" Margin="-14,6,-15,0" VerticalAlignment="Top" Width="210" Template="{StaticResource Button_CurrentLayout1}" RenderTransformOrigin="0.5,0.5" Foreground="#FFCBECCB" FontFamily="Times New Roman" Click="LoadGame_online" FontSize="16"> </Button> </DataTemplate> </ListBox.ItemTemplate> </ListBox>
Then I want to extract the button element:
for (int i = 0; i < Game_ScrollViewer_online.Items.Count; i++) { var tempType = Game_ScrollViewer_online.Items[i].GetType(); Button tempBut = (Game_ScrollViewer_online.Items[i] as Button);
But as said, the return type is a string.
Why is this not a button? And is there a way to access the button?
source share