How to achieve this ui?
item1 | X
item2 | X
item3 | X
with item1,item2,item3 have SelectionChanged event and X is an image with tap event
I tried this
<telerikPrimitives:RadDataBoundListBox
x:Name="AddressListBox"
ItemsSource="{Binding hereRestAddressDetail}"
SelectedItem="{Binding hereRestDetail}"
SelectionChanged="AddressListBox_SelectionChanged"
ItemAnimationMode="PlayAll"
EmptyContent="">
<telerikPrimitives:RadDataBoundListBox.ItemTemplate>
<DataTemplate>
<Grid Margin="0,0,0,10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Rectangle Grid.Column="0" Grid.RowSpan="2" Width="10">
<Rectangle.Fill>
<SolidColorBrush Color="{StaticResource PhoneAccentColor}"/>
</Rectangle.Fill>
</Rectangle>
<StackPanel Grid.Column="1" Grid.RowSpan="2" >
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding LocalizedResources.by,
Source={StaticResource LocalizedStrings}}"
Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock Text="{Binding creator}" Margin="-8,0,0,0"
Style="{StaticResource PhoneTextAccentStyle}"/>
</StackPanel>
<TextBlock Text="{Binding street}"
TextWrapping="Wrap"
Style="{StaticResource PhoneTextLargeStyle}" />
<TextBlock Text="{Binding formatedStreet}"
TextWrapping="Wrap"
Style="{StaticResource PhoneTextSubtleStyle}" />
</StackPanel>
<Image Source="{Binding ratingButton}" Grid.Column="2"
Stretch="Uniform" Width="80"
Tag="{Binding Id}" Tap="rate_Tap"/>
<TextBlock Text="{Binding ratingValue}" HorizontalAlignment="Center"
TextWrapping="Wrap" Grid.Column="2" Grid.Row="1"
Style="{StaticResource PhoneTextSubtleStyle}"/>
</Grid>
</DataTemplate>
</telerikPrimitives:RadDataBoundListBox.ItemTemplate>
</telerikPrimitives:RadDataBoundListBox>
but when I tap into image it will execute my event (in this condition I just testing it with showing messagebox ) but after that it also executing my SelectionChanged event...
how to specify that only image tap event that triggered when I tap into the image?
This should work:
bool ignoreSelectionChanged;
void rate_Tap(...) {
ignoreSelectionChanged = true;
//do you image tap things here
}
void AddressListBox_SelectionChanged(...) {
if(ignoreSelectionChanged) {
ignoreSelectionChanged = false; //reset the bool, so that it will skip only once
return;
}
//do your things on selection change here
}
Related
I have a listbox which I can successfully update with the data but now I want to access two specific textblocks which I want to collapse and make the other visible. here is my xaml:
<ListBox Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="3" HorizontalAlignment="Stretch" Name="myPM_MListBox" Margin="-5,0,-5,0" SelectionChanged="myPMListBox_SelectionChanged">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Margin="0,0,0,0" HorizontalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Border Grid.Row="0" Grid.Column="0" Margin="5,0,0,0" Background="#FF009E49" BorderThickness="1" BorderBrush="#FF505050">
<TextBlock Margin="5,5,5,5" Text="Message Date" FontSize="16" HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Top" Foreground="#FFFFFFFF" FontWeight="Normal" />
</Border>
<Border Grid.Row="0" Grid.Column="1" Margin="0,0,5,0" Background="#FFEFEFEF" BorderThickness="1" BorderBrush="#FF505050">
<TextBlock Margin="5,5,5,5" x:Name="PMMessagePubDate" Text="{Binding shdMsgPublishTime}" FontSize="16" HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Top" Foreground="#FF000000" FontWeight="Normal" />
</Border>
<Border Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Margin="5,0,5,0" Background="#FFEFEFEF" BorderThickness="1,1,1,0" BorderBrush="#FF505050">
<TextBlock Margin="5,5,5,5" x:Name="PM_MLimitedBody" Text="{Binding shdMessageText}" FontSize="16" HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Top" Foreground="#FF000000" FontWeight="Normal" />
</Border>
<Border Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Margin="5,0,5,0" Background="#FFEFEFEF" BorderThickness="1,0,1,1" BorderBrush="#FF505050">
<TextBlock Margin="5,5,5,5" x:Name="PM_MFullBody" Text="Show more..." FontSize="16" HorizontalAlignment="right" TextWrapping="Wrap" VerticalAlignment="Top" Foreground="Blue" FontWeight="Normal" Tapped="ShowFullBody_Tap" />
</Border>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
I want to hide PM_MLimitedBody textblock and show the PM_MFullBody textblock for the ShowFullBody_Tap event handler I have. But seems like I can't access the Visibility properties of these textblok in my .cs file. is there a way for me to access these textblock's visibility property in my .cs file?
You can use the sender of ShowFullBody_Tap will be the TextBox that defines that event. You can then use VisualTreeHelper.GetParent(...) to get the Border and then the Grid and then look at Grid.Children to find the other borders with their textboxes.
I fill my LongListSelector with this template:
<DataTemplate x:Key="LongListSelectorItemTemplate">
<StackPanel Orientation="Horizontal" Margin="4,4">
<Grid Tap="Grid_Tap" x:Uid="{Binding Id}">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Image Grid.RowSpan="3" Width="150" Height="60" Source="{Binding Logo}" VerticalAlignment="Center" Margin="0,0,15,0"/>
<TextBlock Grid.Column="1" Text="{Binding NazwaSklepu}" FontFamily="/Okazjum;component/Fonts/Fonts.zip#Open Sans" VerticalAlignment="Center" HorizontalAlignment="Left" Foreground="Black" FontSize="32"/>
<Image Grid.Column="1" Grid.Row="1" Source="1.0_Images/Vector Smart Object.png" VerticalAlignment="Center" HorizontalAlignment="Left" />
<TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding GodzinyOtwarcia}" FontFamily="/Okazjum;component/Fonts/Fonts.zip#Open Sans Light" VerticalAlignment="Center" HorizontalAlignment="Left" FontSize="14" Foreground="Gray" Margin="25,0,0,0" />
<Image Grid.Column="1" Grid.Row="2" Source="1.0_Images/Vector Smart Object copy 3.png" VerticalAlignment="Center" HorizontalAlignment="Left"/>
<TextBlock Grid.Column="1" Grid.Row="2" Text="{Binding Adres}" FontFamily="/Okazjum;component/Fonts/Fonts.zip#Open Sans Light" VerticalAlignment="Center" HorizontalAlignment="Stretch" FontSize="14" Foreground="Gray" Margin="25,0,0,0" x:Name="txtAdres"/>
</Grid>
</StackPanel>
</DataTemplate>
As you can see I added Tap event to my grid and Binding id.
How can I obtain this Id in my C# event code?
I found temporary way. I put Id in Tag instead of x:Uid
and used following code:
private void Grid_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
int id = -1;
var element = (FrameworkElement)sender;
if (int.TryParse((Grid)element.Tag + "", out id)) {
... my code
}
}
I have page that is using the "Split Page" template and I want it to animate the details whenever a different item is selected in the ListView
My XAML
<!-- Vertical scrolling item list -->
<ListView
x:Name="itemListView"
AutomationProperties.AutomationId="ItemsListView"
AutomationProperties.Name="Items"
TabIndex="1"
Grid.Row="1"
Margin="0,0,0,0"
Padding="120,0,0,60"
ItemsSource="{Binding Source={StaticResource itemsViewSource}}"
IsSwipeEnabled="False"
SelectionChanged="ItemListView_SelectionChanged">
<ListView.ItemTemplate>
<DataTemplate>
<Grid Margin="6">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Image Source="{Binding ImagePathSmall}" Stretch="None" AutomationProperties.Name="{Binding Priority}" />
<StackPanel Grid.Column="1" Margin="10,0,0,0">
<TextBlock Text="{Binding Category}" Style="{StaticResource TitleTextBlockStyle}" TextWrapping="NoWrap" MaxHeight="40"/>
<TextBlock Text="{Binding Patient}" Style="{StaticResource CaptionTextBlockStyle}" TextWrapping="NoWrap"/>
</StackPanel>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<!-- Details for selected item -->
<ScrollViewer
x:Name="itemDetail"
AutomationProperties.AutomationId="ItemDetailScrollViewer"
Grid.Column="1"
Padding="60,0,66,0"
DataContext="{Binding SelectedItem, ElementName=itemListView}"
HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollMode="Disabled" ScrollViewer.VerticalScrollMode="Enabled"
ScrollViewer.ZoomMode="Disabled" Grid.Row="1">
<Grid x:Name="itemDetailGrid" Margin="0,60,0,50">
<Grid.ChildrenTransitions>
<TransitionCollection>
<ContentThemeTransition/>
</TransitionCollection>
</Grid.ChildrenTransitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Image Source="{Binding ImagePath}" Stretch="UniformToFill" AutomationProperties.Name="{Binding Priority}" Width="128" Height="128"/>
<StackPanel x:Name="itemDetailTitlePanel" Grid.Row="1" Grid.Column="1">
<TextBlock x:Name="itemTitle" Margin="0,-10,0,0" Text="{Binding Category}" Style="{StaticResource SubheaderTextBlockStyle}"/>
<TextBlock x:Name="itemSubtitle" Margin="0,0,0,20" Text="{Binding Patient}" Style="{StaticResource SubtitleTextBlockStyle}"/>
</StackPanel>
<TextBlock Grid.Row="2" Grid.ColumnSpan="2" Margin="0,20,0,0" Text="{Binding TaskDetails}" Style="{StaticResource BodyTextBlockStyle}"/>
</Grid>
</ScrollViewer>
From reading Quickstart: Animating your UI using library animations (Windows Runtime apps using C#/VB/C++ and XAML) I should be able to get my desired effect by adding
<Grid.ChildrenTransitions>
<TransitionCollection>
<ContentThemeTransition/>
</TransitionCollection>
</Grid.ChildrenTransitions>
Though it does not have the desired effect. Can qnyone tell me why and how to achieve the desired effect?
Changing it to this has the desired effect
<!-- Vertical scrolling item list -->
<ListView
x:Name="itemListView"
AutomationProperties.AutomationId="ItemsListView"
AutomationProperties.Name="Items"
TabIndex="1"
Grid.Row="1"
Margin="0,0,0,0"
Padding="120,0,0,60"
ItemsSource="{Binding Source={StaticResource itemsViewSource}}"
IsSwipeEnabled="False"
SelectionChanged="ItemListView_SelectionChanged">
<ListView.ItemTemplate>
<DataTemplate>
<Grid Margin="6">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Image Source="{Binding ImagePathSmall}" Stretch="None" AutomationProperties.Name="{Binding Priority}" />
<StackPanel Grid.Column="1" Margin="10,0,0,0">
<TextBlock Text="{Binding Category}" Style="{StaticResource TitleTextBlockStyle}" TextWrapping="NoWrap" MaxHeight="40"/>
<TextBlock Text="{Binding Patient}" Style="{StaticResource CaptionTextBlockStyle}" TextWrapping="NoWrap"/>
</StackPanel>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<!-- Details for selected item -->
<ContentControl x:Name="itemDetail" Content="{Binding SelectedItem, ElementName=itemListView}" Grid.Row="1" Grid.Column="1" >
<ContentControl.ContentTemplate>
<DataTemplate>
<Grid x:Name="itemDetailGrid" Margin="0,60,0,50">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Image Source="{Binding ImagePath}" Stretch="UniformToFill" AutomationProperties.Name="{Binding Priority}" Width="128" Height="128"/>
<StackPanel x:Name="itemDetailTitlePanel" Grid.Row="1" Grid.Column="1">
<TextBlock x:Name="itemTitle" Margin="0,-10,0,0" Text="{Binding Category}" Style="{StaticResource SubheaderTextBlockStyle}"/>
<TextBlock x:Name="itemSubtitle" Margin="0,0,0,20" Text="{Binding Patient}" Style="{StaticResource SubtitleTextBlockStyle}"/>
</StackPanel>
<TextBlock Grid.Row="2" Grid.ColumnSpan="2" Margin="0,20,0,0" Text="{Binding TaskDetails}" Style="{StaticResource BodyTextBlockStyle}"/>
</Grid>
</DataTemplate>
</ContentControl.ContentTemplate>
<ContentControl.ContentTransitions>
<TransitionCollection>
<ContentThemeTransition HorizontalOffset="100"/>
</TransitionCollection>
</ContentControl.ContentTransitions>
</ContentControl>
I have this LongListSelector in my app page:
<Controls:LongListSelector x:Name="searchList" Margin="0,0,0,0" Background="White" SelectionChanged="DidPressSelectSearchList" HorizontalContentAlignment="Stretch" Grid.Row="1">
<Controls:LongListSelector.ItemTemplate>
<DataTemplate>
<local:SearchTemplateSelector Content="{Binding}" HorizontalContentAlignment="Stretch">
<local:SearchTemplateSelector.GoogleSuggestTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Rectangle Height="1" HorizontalAlignment="Stretch" VerticalAlignment="Top" Fill="Black" Opacity="0.3"/>
<TextBlock Text="{Binding}" FontSize="25" Foreground="Black" TextWrapping="Wrap" Grid.Row="1" Margin="0,10"/>
</Grid>
</DataTemplate>
</local:SearchTemplateSelector.GoogleSuggestTemplate>
<local:SearchTemplateSelector.VideoTemplate>
<DataTemplate>
<Grid>
<Rectangle Height="1" HorizontalAlignment="Stretch" VerticalAlignment="Top" Fill="Black" Opacity="0.3" />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Image Margin="0" Source="{Binding Path=ImgUrl}" HorizontalAlignment="Left" Width="100" Height="100" Tag="{Binding idStr}"/>
<Grid Grid.Column="1" Margin="10,0,8,0">
<Grid.RowDefinitions>
<RowDefinition Height="60"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Text="{Binding Name}" FontSize="20" Foreground="Black" TextWrapping="Wrap" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
<StackPanel Orientation="Horizontal" Margin="0,-5,0,0" Grid.Row="1">
<TextBlock Text="Views: " FontSize="20" Foreground="Black"/>
<TextBlock Text="{Binding ViewCount}" FontSize="20" Foreground="Black"/>
</StackPanel>
<Grid Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding TimeStr}" FontSize="20" Foreground="Black" Margin="0,0,0,0" />
<TextBlock Text="Cached" FontSize="20" Foreground="Red" Margin="20,0,0,0" Grid.Column="1" />
</Grid>
</Grid>
</Grid>
</Grid>
</DataTemplate>
</local:SearchTemplateSelector.VideoTemplate>
</local:SearchTemplateSelector>
</DataTemplate>
</Controls:LongListSelector.ItemTemplate>
</Controls:LongListSelector>
And i noticed that when i press a item in the list so the user not have any thing to know which item he pressed, something like focus the item when he press it.
In iPhone the the selected row get blue and when release the blue selection is disappear,there is some equivalent to this in windows phone too?
Use TiltEffect from Silverlight Toolkit for Windows Phone, details are here http://www.geekchamp.com/articles/silverlight-for-wp7-toolkit-tilteffect-in-depth. Also to make an effect more expressive use Button as a container for your ItemTemplate with EmptyButtonStyle http://www.jeff.wilcox.name/2011/10/hyperlinkbutton-empty-style-for-phone/.
I have a collection which shows in listbox. It's a listBoxItem of major listBox. Each listbox's item(not major) has a textbox and button. So, i need to get all collection when I tap on any button in listbox.
This is windows pnone 7 application. I want to get a list of items that are in listbBox.
I know how to get one item if it's not a collection(just item of major listBox)
private void Audio_Button_Click(object sender, RoutedEventArgs e)
{
string uri = null;
TextBox tb = null;
var grid = (Grid)((Button)sender).Parent;
foreach (var child in grid.Children)
{
if (child is TextBox && (string)((TextBox)child).Tag == "URL")
{
tb = (TextBox)child;
}
}
uri = tb.Text;
but i dont know how to get all the items. The problem is in that the "sender" has type button, not a listBoxItem. And anyway, if it had type listBoxItem - i'm not sure i understand how to make a list of items(
Or maybe i can use another control, with out scrolling? collection is not very big. But i think i'll have the same problem(
Update:
<local:NewsTemplateSelector.Audio>
<DataTemplate>
<Grid Name="AudioGrid" MaxHeight="2000">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="75"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="75"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="28"/>
</Grid.RowDefinitions>
<Image Source="{Binding SourceImage}" Width="75"/>
<TextBlock Text="{Binding SourceName}" Foreground="Black" FontSize="25" Grid.Column="1" TextWrapping="Wrap" />
<TextBlock Text="{Binding Texts}" Foreground="Black" FontSize="25" Grid.Column="1" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top" Height="auto" />
<Image Source="{Binding Photo[0].Big}" Margin="10" Grid.Column="1" Grid.Row="2"/>
<TextBlock Text="{Binding Audio[0].Title}" Foreground="Black" FontSize="25" Margin="96,10,10,10" Grid.Column="1" Grid.Row="3" />
<Button Background="Black" Content="Play" Grid.Column="1" HorizontalAlignment="Left" Margin="10,7,0,10" Grid.Row="3" d:LayoutOverrides="Height" Width="74" Tap="Audio_Button_Click" />
<Image Source="images\like.jpg" Grid.Column="1" HorizontalAlignment="Right" Grid.Row="4" Width="30" Margin="0,1.5,34,-1.5" d:LayoutOverrides="VerticalMargin"/>
<TextBlock Text="{Binding Likes}" Grid.Column="1" HorizontalAlignment="Right" Grid.Row="4" Foreground="Black" TextWrapping="Wrap" Width="30" Margin="0,0.5,0,-0.5"/>
<Line X1="0" Y1="27" X2="420" Y2="27" Margin="0,-28,0,0" Stroke="Gray" StrokeThickness="1" Grid.Column="1" />
<Line X1="0" Y1="27" X2="80" Y2="27" Margin="0,-28,0,0" Stroke="Gray" StrokeThickness="1" />
<TextBox Text="{Binding Audio[0].Url}" Tag="URL" Visibility="Collapsed" />
</Grid>
</DataTemplate>
</local:NewsTemplateSelector.Audio>
and
<local:NewsTemplateSelector.Audios>
<DataTemplate>
<Grid Name="AudiosGrid" MaxHeight="2000">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="75"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="75"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="28"/>
</Grid.RowDefinitions>
<Image Source="{Binding SourceImage}" Width="75"/>
<TextBlock Text="{Binding SourceName}" Foreground="Black" FontSize="25" Grid.Column="1" TextWrapping="Wrap" />
<TextBlock Text="{Binding Texts}" Foreground="Black" FontSize="25" Grid.Column="1" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top" Height="auto" />
<Image Source="{Binding Photo[0].Big}" Margin="10" Grid.Column="1" Grid.Row="2"/>
<ListBox Name="audiosListbox" ItemsSource="{Binding Audio}" MaxHeight="500" Margin="10" Grid.Column="1" Grid.Row="3" >
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Title}" Grid.Column="1" Foreground="Black" FontSize="25" />
<Button Content="Play" Background="Black" Tap="Audios_Button_Click" />
<TextBox Text="{Binding Audio.Url}" Tag="URL" Visibility="Collapsed" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Image Source="images\like.jpg" Grid.Column="1" HorizontalAlignment="Right" Grid.Row="4" Width="30" Margin="0,1.5,34,-1.5" d:LayoutOverrides="VerticalMargin"/>
<TextBlock Text="{Binding Likes}" Grid.Column="1" HorizontalAlignment="Right" Grid.Row="4" Foreground="Black" TextWrapping="Wrap" Width="30" Margin="0,0.5,0,-0.5"/>
<Line X1="0" Y1="27" X2="420" Y2="27" Margin="0,-28,0,0" Stroke="Gray" StrokeThickness="1" Grid.Column="1" />
<Line X1="0" Y1="27" X2="80" Y2="27" Margin="0,-28,0,0" Stroke="Gray" StrokeThickness="1" />
</Grid>
</DataTemplate>
</local:NewsTemplateSelector.Audios>
I have
You could use Linq To Visual Tree (download code, just one file) to get the Listbox that holds all the items. This code on the click handler should work for it.
var parentLb = ((Button)sender).Ancestors().FirstOrDefault(x => x is Listbox) as Listbox;
if(parentLb != null)
{
// Cast the ItemsSource property to the list type you're using...
var list = parentLb.ItemsSource
// And do whatever you want with that list.
}
You should of course cast list to its original type.