Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8423077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:38:04+00:00 2026-06-10T03:38:04+00:00

I am trying to create secondary live tiles for my application based upon the

  • 0

I am trying to create secondary live tiles for my application based upon the click event of a contextmenu, and I need to expose some properties of the ContextMenu’s parent object but I am unsure of how to do this. Basically, I have two HubTiles on my MainPage, and each use the same ContextMenu click event. In the ContextMenu click event MenuItem_Tap, I call a method CreateLiveTile which should get properties of the HubTile where the contextmenu click occured for use in the secondary tile that will be pinned to the start screen. What I have is as follows, but I do not know how to expose the properties of the HubTile where the ContextMenu click occured

MainPage.xaml

 <ListBox Grid.Row="0" x:Name="tileList" toolkit:TiltEffect.IsTiltEnabled="True">
                <ListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <toolkit:WrapPanel Orientation="Horizontal" />
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <toolkit:HubTile Title="{Binding Title}" Margin="3"
                                         Notification="{Binding Notification}"
                                         DisplayNotification="{Binding DisplayNotification}"
                                         Message="{Binding Message}"
                                         GroupTag="{Binding GroupTag}"
                                         Source="{Binding ImageUri}"
                                         Tap="hubTile_Tap">
                            <toolkit:ContextMenuService.ContextMenu>
                                <toolkit:ContextMenu x:Name="menu">
                                    <toolkit:MenuItem Header="pin to start" Tap="MenuItem_Tap"/>
                                </toolkit:ContextMenu>
                            </toolkit:ContextMenuService.ContextMenu>
                        </toolkit:HubTile>

                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>

MainPage.xaml.cs

public MainPage()
    {
        InitializeComponent();

        CreateHubTiles();
    }

private void CreateHubTiles()
    {
        List<TileItem> tileItems = new List<TileItem>() 
        {
            new TileItem() { ImageUri = "/Images/shareStatusImage.jpg", Title = "status", /*Notification = "last shared link uri",*/ Message = Settings.statusMessage.Value, GroupTag = "TileGroup" },
            new TileItem() { ImageUri = "/Images/shareLinkImage.jpg", Title = "link", /*Notification = "last shared status message",*/ Message = "last shared link uri", GroupTag = "TileGroup" }, 
        };

        this.tileList.ItemsSource = tileItems;
    }

private void MenuItem_Tap(object sender, System.Windows.Input.GestureEventArgs e)
    {
        //How to expose which HubTile was selected and its properties?
        //HubTile tap = sender as HubTile;  //not working, sent from ContextMenu not HubTile

        //(sender as MenuItem).
        //(sender as UIElement).
        //string parent = VisualTreeHelper.GetParent((sender as DependencyObject)).ToString();

        //attempt to pass the selected HubTile instance to CreateLiveTiles method
        CreateLiveTile(tap);
    }

    private void CreateLiveTile(HubTile hubtile)
    {
        string _title = hubtile.Title.ToString();

        //var Tile = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("DefaultTitle=" + LiveTile.Title));
        var Tile = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("DefaultTitle=" + _title));

        if (Tile == null)
        {
            try
            {
                var LiveTile = new StandardTileData
                {
                    Title = hubtile.Title,
                    BackgroundImage = ((System.Windows.Media.Imaging.BitmapImage)hubtile.Source).UriSource,
                    //Count = 1,
                    BackTitle = hubtile.Title,
                    //BackBackgroundImage = new Uri("", UriKind.Relative),
                    BackContent = hubtile.Message,
                };

                ShellTile.Create(new Uri("/MainPage.xaml?DefaultTitle=" + LiveTile.Title, UriKind.Relative), LiveTile);
            }
            catch (Exception)
            {
                MessageBox.Show("This tile could not be pinned", "Warning", MessageBoxButton.OK);
            }
        }
        else
        {
            MessageBox.Show("This tile has already been pinned", "Notice", MessageBoxButton.OK);
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T03:38:05+00:00Added an answer on June 10, 2026 at 3:38 am

    PlacementTarget is what you looking for, if sender is MenuItem then its parent will be ContextMenu and from that you can get the PlacementTarget where this contextMenu is placed.

    private void MenuItem_Tap(object sender, System.Windows.Input.GestureEventArgs e)
    {
       HubTitle tap = (((sender as MenuItem).Parent as ContextMenu).PlacementTarget
                                                                as HubTitle);
    
       //attempt to pass the selected HubTile instance to CreateLiveTiles method
       CreateLiveTile(tap);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to create a secondary view to my main view. This subview needs
I'm trying to create a chart using highcharts to represent some data. However i'm
I am trying to create a WPF presentation application where the Primary Window on
I have been trying to work out a few reports based off some log
I'm trying create a bot which automatically likes Facebook posts. Using Mechanize I can
I am trying create a delegate representation of constructor by emitting a Dynamic Method,
Ok so I am trying create a login script, here I am using PHP5
Trying to create a black line in my view to separate text blocks but
Trying to create a facebook app just to learn and coming across a strange
Trying to create a new Dedicated Cache Role in Windows Azure but get the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.