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 9160253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:41:40+00:00 2026-06-17T13:41:40+00:00

I have a MainWindow.xaml with a ScatterView which has a TagVisualization.xaml that appears when

  • 0

I have a MainWindow.xaml with a ScatterView which has a TagVisualization.xaml that appears when a tag is placed. Inside that TagVisualization, I have a PhotoGallery.xaml that has a LibraryBar, which is populated by an outside class called PhotoGalleryViewModel.cs. I have implemented the DragDropScatterView class so I can drag the items from the LibraryBar and drop them on the ScatterView. When a new ScatterViewItem is created it has a close button. When I click it the item is supposed to be removed from the ScatterView and re-enabled on the LibraryBar. My problem is with the re-enabling of the item, because I can’t seem to get to the PhotoGallery.xaml.

A while ago I had something similar and someone gave me the following solution:

private void SurfaceButton_TouchDown(object sender, TouchEventArgs e) {
    ScatterViewItem _host = MyApplication.Helpers.VisualTree.FindVisualParent<ScatterViewItem>(this);

    if (_host != null) {
        DependencyObject parent = VisualTreeHelper.GetParent(this);
        ScatterViewItem svi = null;
        while (parent as DragDropScatterView == null)
        {
            if (parent is ScatterViewItem)
                svi = parent as ScatterViewItem;
            parent = VisualTreeHelper.GetParent(parent);
        }

        // Access directly to the LibraryBar
        LibraryBar lb = _host.Tag as LibraryBar;
        lb.SetIsItemDataEnabled(_host.Content, true);

        ((DragDropScatterView)parent).Items.Remove(this.DataContext);
    }

However, in my present project, this does not work because the _host.Tag is always null.
I managed to come up with this:

private void scatterCloseButton(object sender, TouchEventArgs e) {
    ScatterViewItem _host = MyApplication.Model.VisualTree.FindVisualParent<ScatterViewItem>(this);

    if (_host != null) {

        DependencyObject parent = VisualTreeHelper.GetParent(this);
        ScatterViewItem svi = null;
        while (parent as DragDropScatterView == null) {
            if (parent is ScatterViewItem)
                svi = parent as ScatterViewItem;
            parent = VisualTreeHelper.GetParent(parent);
        }

        // The data of the item
        PhotoGalleryViewModel lb = _host.DataContext as PhotoGalleryViewModel;

        if (lb != null) {
            // The Tag Visualizer relative to that tag
            TagVisualizer tagVisualizer = SurfaceFiturApp.Model.VisualTree.FindVisualParent<TagVisualizer>(this);
            if (tagVisualizer != null) {
                // The PhotoGallery object where the gallery is in
                PhotoGallery photoGallery = SurfaceFiturApp.Model.VisualTree.FindVisualChild<PhotoGallery>(tagVisualizer);
                if (photoGallery != null) {
                    // Enable the item in the library
                    photoGallery.setLibraryItemEnabled(lb);
                }
            }
        }

        // Remove the object from the ScatterView
        ((DragDropScatterView)parent).Items.Remove(this.DataContext);

    }

}

But the problem with this (apart from it’s inneficiency, because I come all the way up to the TagVisualization and go all the way to get the LibraryBar) is that I can’t differentiate different LibraryBar's, i.e., if I have two tags on the surface, only one of them will get the item re-enabled, the others just don’t do aything.

So my question is: Given the first chunck of code, how can I make it work for me? How can I, from there, reach my LibraryBar, i.e., go all the way from the ScatterViewItem (PhotoGalleryViewModel) to the LibraryBar that’s inside a TagVisualization, that’s, in it’s turn, is inside a MainWindow with a ScatterView?

  • 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-17T13:41:41+00:00Added an answer on June 17, 2026 at 1:41 pm

    I managed to solve my problem, on my DragDropScatterView.cs I need to save my dragSource to the ScatterViewItem, so I can later on activate it. So I add the following code:

    private void OnCursorDrop(object sender, SurfaceDragDropEventArgs args) {
        (...)
        svi.Tag = droppingCursor.DragSource;
        (...)
    }
    

    And this way I can use the first part of code displayed on my first post, because now I have the dragSource.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Guys, I have a basic WPF application. Contains App.xaml as always and a Mainwindow.xaml.
I have the following code: <Window x:Class=kkk.MainWindow xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml Title=MainWindow Height=350 Width=525> <Window.Resources> <Style
i have a window which is like this <Window x:Class=pharmacy_Concept.MainWindow xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml Title=MainWindow Height=350
I have a view that is loaded in the MainWindow.xib. It is just a
In my MainWindow.xaml, I have the following reference to a ResourceDictionary: <Window.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries>
I Have a ResourceDictionary Generic.xaml which consists of a set of other resource dictionaries,
I have an object that has a timer and it throws an event when
I have a WPF app that I'm testing which loads a XML and visualizes
In my MainWindow.xaml, I have added my UserControl to the Window. There is also
I have a solution with these projects: 1. Clinica (Type is Windows Application),( MainWindow.xaml

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.