1.2.2.4 - GoWPF - Dynamic Filtering

Hi Walter,

I am implementing a dynamic node filter.

I have a custom PartManager that implements FilterNodeForData.

I have a button that can toggle a filter state. When button is pressed, I call PartManager.RebuildNodeElements();

This seems to work, it will filter properly. However, 99% of the time when transitioning from unfiltered to filtered, my diagram layout will go “blank” (it will show no nodes).

For debugging, I implemented the Diagram LayoutCompleted event handler. I set a breakpoint in this method, and can confirm that it is being called when a “blank” layout is drawn. If I then resize my window, the LayoutCompleted event handler gets called again, and then the diagram is no longer blank. (displays as i would expect)

It’s curious, this only occurs when I am filtering data, when I toggle back to an unfiltered state, it always draws the diagram correctly the first time.

Unfiltered --> click filter button --> RebuildNodeElements --> FilterNodeForData --> LayoutCompleted (blank). Manually resize window containing diagram --> LayoutCompleted --> (not blank)

Filtered --> click filter button --> RebuildNodeElements --> FilterNodeForData --> LayoutCompleted (not blank)

I guess my question is, is this the correct approach?

    public class GoXamCustomPartManager : PartManager
    {
        /// <summary>
        /// FilterNodeForData
        /// </summary>
        /// <param name="item"></param>
        /// <returns>
        /// False - Item will be filtered out
        /// True  - Item will not be filtered out
        /// </returns>
        protected override bool FilterNodeForData(object nodedata, Northwoods.GoXam.Model.IDiagramModel model)
        {
            BusinessEntityGoXamViewModel begxvm = nodedata as BusinessEntityGoXamViewModel;
            if (begxvm != null)
            {
                bool retVal = begxvm.BusinessEntitySearch(begxvm);
                return (retVal);
            }
            else
            {
                return (base.FilterNodeForData(nodedata, model));
            }
        }
    }


....
....
....

        /// <summary>
        /// Filter
        /// </summary>
        /// <param name="item"></param>
        /// <returns>
        /// False - Item will be filtered out
        /// True  - Item will not be filtered out
        /// </returns>
        public virtual bool BusinessEntitySearch(object item)
        {
            BusinessEntityBaseViewModel bebvm = item as BusinessEntityBaseViewModel;
            if (bebvm == null)
            {
                return (false);
            }
            else if (((_FilterResponder == true) && (bebvm.Data.Type == Enum_ProxySalIDType.Responder)) ||
                     ((_FilterEquipment == true) && (bebvm.Data.Type == Enum_ProxySalIDType.Equipment))
                    )
            {
                return (false);
            }
            else
            {
                return (true);
            }
        }

OK, I just tried a test case, and it worked fine for me: no problems showing either the restricted subset of nodedata/nodes or all of them.

Could you provide some more information for how I can reproduce the problem?

Hi Walter,

I looked into this a bit further. I have found a few things.
So I want to modify the Diagram Default Style. To achieve this, I fire up Expression Blend, select my Diagram, right click Edit Template -> Edit a Copy. This produces :
[code]










































Comment
LinkLabel

























































































































































































Comment



















































[/code]
So If I try to compile and run after this, I get 3 errors : Property 'Key' does not have a value.
Hmm... well I'm not sure how to resolve those things, so I'll just reduce the style to (this is probably a bad idea... but I dont know what else to do) :
[code]
















[/code]
recompile, test filtering, so far, so good, everything is working as expected.
So now I would like the horizontal and vertical scrollbars to always be visible, so I update them from Auto to Visible.
[code]
















[/code]
Recompile, and test filtering, I can now reporduce my original issue :(
So I am wondering :
Why doesn't the Deafult Style work?
Why does setting the scroll bar visiblity break functionality?

Blend produced invalid XAML when it extracted the Diagram’s Style to make a copy of it for you to edit. It should know better about how to handle Dictionaries.

I just tried using your modified DiagramStyle1, and it worked fine for me with an Overview observing the re-styled Diagram and then clicking a Button which toggles the filtering of a custom PartManager and then calls RebuildNodeElements().

Maybe I’ll try other cases tomorrow.

Oh, perhaps you didn’t make sure your Overview had its own CustomPartManager and that changing your filter changed it the same way in both CustomPartManagers and called RebuildNodeElements() on both?

I’m just trying to guess as to the problem.

It’s very odd that scroll bar visibility has anything to do with it.

This morning, I tried to reproduce the problem in an example project that I could send to you, however, my example project works fine. So it’s something in my application that is not working. I’ll keep searching for the cause.

Hi Walter, I managed to reproduce this in a contained project. I have reviewed the implementation with a colleague and we are at a loss for what the issue is. I am sending the project in an email.