How to connect secondary chunks for each viewed list item in Windows 8.1 phone.

I am showing a list box on another page when a click on a list item is clicked on a control dragged to another page that I was bound on that clicked data.

I can connect a secondary slab to one event to trigger a panel using a pin panel button.

Indicates that the page is already attached.

Now I would like to hover new tiles for each click list item.

I can get the id of the selected item in the list.

So, is it possible to check each id, whether the pinbar is activated or not.?

Here is the code I wrote: -

     private void ToggleAppBarButton(bool showPinButton)
    {
        if (showPinButton)
        {
            this.PinUnPinCommandButton.Label = "Pin to start";
            this.PinUnPinCommandButton.Icon = new SymbolIcon(Symbol.Pin);
        }
        else
        {
            this.PinUnPinCommandButton.Label = "Unpin from start";
            this.PinUnPinCommandButton.Icon = new SymbolIcon(Symbol.UnPin);
        }

        this.PinUnPinCommandButton.UpdateLayout();
    }


    void Init()
    {
        ToggleAppBarButton(!SecondaryTile.Exists(EditWindow.appbarTileId));
        this.PinUnPinCommandButton.Click += this.pinToAppBar_Click;
    }

    async void pinToAppBar_Click(object sender, RoutedEventArgs e)
    {
        this.SecondTileCommmandbar.IsSticky = true;

        if (SecondaryTile.Exists(EditWindow.appbarTileId))
        {
            SecondaryTile secondarytile = new SecondaryTile(EditWindow.appbarTileId);


            bool ispinned = await secondarytile.RequestDeleteForSelectionAsync(EditWindow.GetElementRect((FrameworkElement)sender), Windows.UI.Popups.Placement.Above);
            ToggleAppBarButton(ispinned);

        }
        else
        {
            Uri square150x150Logo = new Uri("ms-appx:///Assets/SmallScreen.scale-140.png");
            string tileActivationArguments = EditWindow.appbarTileId + " WasPinnedAt=" + DateTime.Now.ToLocalTime().ToString();

            string displayName = daysleft.Events = event_text.Text;

            SecondaryTile secondaryTile = new SecondaryTile(EditWindow.appbarTileId, 
                                                            displayName, 
                                                            tileActivationArguments,
                                                            new Uri("ms-appx:///Assets/Square71x71Logo.scale-140.png"), TileSize.Square150x150);
            secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = true;

            await secondaryTile.RequestCreateAsync();

        }
        this.BottomAppBar.IsSticky = false;
    }

    void BottomAppBar_Opened(object sender, object e)
    {
        ToggleAppBarButton(!SecondaryTile.Exists(EditWindow.appbarTileId));
    }

    private static Rect GetElementRect(FrameworkElement frameworkElement)
    {
        GeneralTransform buttonTransform = frameworkElement.TransformToVisual(null);

        Point point = buttonTransform.TransformPoint(new Point());

        return new Rect(point, new Size(frameworkElement.ActualWidth, frameworkElement.ActualHeight));
             }

    private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
    {

    }

    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
        //accesing clicked listview item from different page 
        Selected_DaysId = Int32.Parse(e.Parameter.ToString());
        Debug.WriteLine("Selected_DaysId "+Selected_DaysId);
       //Method to initialize the pin appbar
        Init();
    }

    protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
    {
        base.OnNavigatingFrom(e);
        if (e.NavigationMode == NavigationMode.Back)
        {
            ResetPageCache();
        }
    }

    private void ResetPageCache()
    {
        var cacheSize = ((Frame)Parent).CacheSize;
        ((Frame)Parent).CacheSize = 0;
        ((Frame)Parent).CacheSize = cacheSize;
    }

      

+3


source to share


1 answer


From what I understood, you want to know if a specific id has already been set or not.

bool isPinned = await secondaryTile.RequestCreateAsync();

      

this returns false if the tile is already pinned, you can create a new secondary tile using the same id you would first create it with and check if ispinned is true or false. this way you will know if your tile has been pinned or not.



EDIT After resolving the discussion solution was reached

if (SecondaryTile.Exists(Selected_DaysId.ToString())) 
{ 

var secondaryTile = new SecondaryTile( 
Selected_DaysId.ToString(), 
"Text shown on tile", 
"secondTileArguments", 
new Uri("ms-appx:///Assets/image.jpg", UriKind.Absolute), 
TileSize.Square150x150); 
bool isPinned1 = await secondaryTile.RequestDeleteAsync(); 
}

      

+1


source







All Articles