This question is locked. New answers and comments are not allowed.
Hi, so i want to bind into contextmenu and i tried this
and i just can't getting "id" that i bind into "tag" in contextmenu, it show null, so how do i can get this "id"?
<
telerikPrimitives:RadDataBoundListBox
x:Name
=
"NearbyListBox"
Visibility
=
"Visible"
SelectionChanged
=
"NearbyListBox_SelectionChanged"
SelectedItem
=
"{Binding hereNearbySelected, Mode=TwoWay}"
ItemsSource
=
"{Binding hereNearby}"
ItemAnimationMode
=
"PlayAll"
ItemAnimationEnded
=
"NearbyListBox_ItemAnimationEnded"
EmptyContent
=
"{Binding}"
>
<
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"
>
<!--<
TextBlock
Text="{Binding
ElementName
=
MainListBox
,
Converter={StaticResource RowIndexConverter}}"/>-->
<
TextBlock
Text
=
"{Binding title}"
TextWrapping
=
"Wrap"
Style
=
"{StaticResource PhoneTextLargeStyle}"
/>
<
TextBlock
Text
=
"{Binding category.title}"
TextWrapping
=
"Wrap"
Style
=
"{StaticResource PhoneTextAccentStyle}"
/>
<
TextBlock
Text
=
"{Binding vicinity}"
TextWrapping
=
"Wrap"
Style
=
"{StaticResource PhoneTextSubtleStyle}"
FontFamily
=
"Portable User Interface"
/>
</
StackPanel
>
<
Image
x:Name
=
"nearbyTap"
Source
=
"{Binding iconPath}"
Grid.Column
=
"2"
Stretch
=
"Uniform"
Width
=
"80"
Tag
=
"{Binding id}"
Tap
=
"nearbyTap_Tap"
/>
<
TextBlock
Text
=
"{Binding distance, StringFormat=\{0:0 m\}}"
TextWrapping
=
"Wrap"
Grid.Column
=
"2"
Grid.Row
=
"1"
Style
=
"{StaticResource PhoneTextSubtleStyle}"
/>
</
Grid
>
</
DataTemplate
>
</
telerikPrimitives:RadDataBoundListBox.ItemTemplate
>
<
telerikPrimitives:RadContextMenu.ContextMenu
>
<
telerikPrimitives:RadContextMenu
x:Name
=
"menu"
Opening
=
"OnMenuOpening"
>
<
telerikPrimitives:RadContextMenuItem
Content
=
"add as favorite place"
x:Name
=
"favNearby"
Tag
=
"{Binding id}"
Tap
=
"favNearby_Tap"
/>
</
telerikPrimitives:RadContextMenu
>
</
telerikPrimitives:RadContextMenu.ContextMenu
>
<
telerikPrimitives:RadDataBoundListBox.ItemAddedAnimation
>
<
telerikCore:RadMoveYAnimation
StartY
=
"500"
EndY
=
"0"
Duration
=
"0:0:1"
>
<
telerikCore:RadMoveYAnimation.Easing
>
<
CubicEase
EasingMode
=
"EaseIn"
/>
</
telerikCore:RadMoveYAnimation.Easing
>
</
telerikCore:RadMoveYAnimation
>
</
telerikPrimitives:RadDataBoundListBox.ItemAddedAnimation
>
<
telerikPrimitives:RadDataBoundListBox.EmptyContentTemplate
>
<
DataTemplate
>
<
TextBlock
Text
=
"{Binding myMessage}"
TextWrapping
=
"Wrap"
HorizontalAlignment
=
"Left"
VerticalAlignment
=
"Top"
Style
=
"{StaticResource PhoneTextGroupHeaderStyle}"
FontFamily
=
"Portable User Interface"
/>
</
DataTemplate
>
</
telerikPrimitives:RadDataBoundListBox.EmptyContentTemplate
>
</
telerikPrimitives:RadDataBoundListBox
>
private void favNearby_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
string id = (string)((RadContextMenuItem)sender).Tag;
string name = "";
string category = "";
string icon = "";
string href = "";
for (int i = 0; i <
mvm.hereNearby.Count
; i++)
{
if (mvm.hereNearby[i].id == id)
{
name
=
mvm
.hereNearby[i].title;
category
=
mvm
.hereNearby[i].category.title;
icon
=
mvm
.hereNearby[i].iconPathSquare;
href
=
mvm
.hereNearby[i].href;
if (mvm.savedPlaces.Where(x => x.name == name).Count() <
1
&& !string.IsNullOrWhiteSpace(name))
{
mvm.savedPlaces.Add(new SavedPlaces {
name
= name,
category
= category,
icon
= icon,
href
= href });
IsoStoreHelper.SaveList<SavedPlaces>("savedPlaces", "location", mvm.savedPlaces);
}
}
}
}
and i just can't getting "id" that i bind into "tag" in contextmenu, it show null, so how do i can get this "id"?