.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

visual tree hit test not working

Posted By:      Posted Date: September 01, 2010    Points: 0   Category :WPF
I have a sketch/designer type of program. The user can sketch shapes. These shapes are polygons in a user control. I have an edge and a vertex class which generate the point collection for my polygons and connect the vertices to outline the polygon. I am using a selection box in an adorner to selection those controls and move them around. When I release the mouse after drawing the selection box, I run a hit test by calling VisualTreeHelper.HitTest. I pass in new     GeometryHitTestParameters(new RectangleGeometry(rect)) where the rectangle is the selection box, and this chooses the appropriate shapes. The user can take the selected shapes and "join" them to unselected shapes. In this situation. The shapes still remain in separate user controls, but they now share the common edges and vertices. At this point, my selection stops working intermittently. When I try to debug my hit test, I never hit the break points in my HitTestFilterCallback, HitTestResultCallback, or in my overridden HitTestCore functions. Then if I drag an edge or vertex, the selection may or may not start working again. I am not even sure how to debug this type of problem anymore. I have checked the visual tree for the canvas holding my shape controls and everything seems right.   Please help.  

View Complete Post

More Related Resource Links

Logical- and Visual Tree

Elements of a WPF user interface are hierarchically related. This relation is called the LogicalTree. The template of one element consists of multiple visual elements. This tree is called the VisualTree. WPF differs between those two trees, because for some problems you only need the logical elements and for other problems you want all elements.

Share The Load: Report Visual Studio Team System Load Test Results Via A Configurable Web Site


This article discusses a new load test tool in Visual Studio 2005 Team System for performance and stress testing your Web sites, Web services, and other server components. Combined with its handy reporting capabilities, the load test tool provides some powerful options for sharing and managing test results.

Wen Ding

MSDN Magazine June 2006

Test: Build Quick and Easy UI Test Automation Suites with Visual Studio .NET


The .NET Framework provides a surprising new way to quickly and easily create user interface test automation. By using objects in the System.Reflection and System.Threading namespaces, you can write automated tests in minutes instead of hours. This article walks you through the building of a typical Windows-based application that will be used as the test subject. The author then runs through the creation of a C#-based test tool that simulates clicking the test app's UI controls and checks the application's state. After the tool is built, the author explains in detail how it works so you can modify and extend it for your own use.

James McCaffrey

MSDN Magazine January 2003

Viewing the Visual Tree in the Debugger

I recently posted an article to CodeProject which discusses a debugger visualizer.  It allows you to view the visual tree while debugging, inspect every property of any element in the tree, as well as view a snapshot image of any element.  I call it Woodstock, because it's like a scaled down version of Snoop.  Here's the article, if you're interested: http://www.codeproject.com/useritems/WoodstockForWPF.asp

Test Menu in Visual Studio 2008

Hi,   I am trying to use unit testing with Asp.NET MVC2 in Visual Studio 2008. But I am not getting the Test menu for running the test project. I have installed Visual Studio standard edition. Can anybody please help me?Regards,Dummybullet. 

Simple test not working

Hi all,  I've created a dummy test that does absolutely nothing. When I try to run it I get the following message: Error TestMethod1 TestProject Unable to get type TestProject.UnitTest1, TestProject. Error: System.BadImageFormatException: Could not load file or assembly 'TestProject, Version=, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format. ... I compiled with platform set to x64, ma machine is a 64 bits and visual studio is not apparently [is installed in C:\Program Files (x86)]. I don't know exactly what .Net is installed. Struggling to really find out how to check that. Any ideas, Thanx, --mike

Ldap authenication code is not working with IIS but works with Visual Studio developement webserver

Hi,I have weird issue here, I have a method that  takes a login Id and authenticates with LDAP active directory and returns the employee Id.It works great when I run the application in Visual studio 2008 ( it uses the default visual studio developement webserver). The code authenitcates the login id and returns emp Id perfectly. But the problem comes when I publish the code to the Local IIS in my developement PC.public string GetEastWestTeamMembersEmployeeID(string loginID)        {            string domain = string.Empty;            string login = string.Empty;            int position = loginID.IndexOf(@"\");            string empid = "";                  System.DirectoryServices.DirectoryEntry directoryEntry = null;            if (position >= 0)            {                domain = loginID.Substring(0, position);    &n

Visual Studio 2008 Web Test Option Missing

I initially installed Visual Studio 2008 Developer edition.  I then installed Visual Studio 2008 Suite edition, with 2008 Developer edition still on the PC.  When attempting to create a new Web Test, this option is not available to select when adding a new test in the solution.  The steps I followed: 1) Create new Project:  Test Project 2) Add "New Test" 3) At this point I would expect "Web Test" to be an option, I only have Ordered Test, Unit Test, and Unit Test Wizard.   Do I need to uninstall Visual Studio 2008 and start with a clean Visual Studio 2008 Suite to get the "Web Test" option to show?

Cross Reference in the Visual Tree


Hi all , I have some problem when I want to make some visual element in my user control to static . 

I found it is because the visual in the visual tree can only have 1 parent , if rendered a new user control , the old one will lose the static elements .

Do you have any idea that I can share the static element in the user controls ?


wpfperf tool Visual Profiler not populating element tree

I'm trying to use the latest version of the Performance Profiling Tools for WPF that are listed here: http://windowsclient.net/wpf/perf/wpf-perf-tool.aspx#profiler

For some reason the element tree is not being populated when I start my app using the Launch Process.  I do see the chart for Application CPU Usage update and scroll by, however I would like to see which elements in particular are eating up CPU time.

Does anyone have a solution?

Visual Studio WebBrowser control's PrintPreviewDialog generates "VSHost32.exe has stopped working"


I'm getting a problem with a VS 2008 application when I use the WebBrowser control's .ShowPrintPreviewDialog method and either print or close the dialog box.  I'm working on a 64-bit Windows 7 computer and using Visual Studio's default Debug option settings.  The problem happens both when running from the IDE in debug mode and after compiling in x86 mode as a stand-alone.

The control is central to as an otherwise effective report management system, so on btnPrint_Click I assign HTML code to .DocumentText and then call .ShowPrintPreviewDialog, which works fine, other than it does need 2 clicks so it seems both stages have to happen as separate events? 

Although when I go to print, the document prints okay, the print preview dialog form closes itself and whole program crashes with the above message.  I've also tried separating those stages to avoid the 2-click issue, but I still get the crash.

If I turn Project>Properties>Debug>"Enable unmanaged code debugging" ON, I get this message instead "Unhandled exception at 0x752c77df (urlmon.dll) in PMPos.exe: 0xC0000005: Access violation reading location 0x00000001."

The control's other print dialog methods work fine.   Is there a solution that I can rely on when distributing the application or am I best abondoning this particular

Visual tree with collapsed elements -Performance



I have a very large and deep visual tree.I had an issue with tab switch .It use to build the visual elements when the focus is on a tab and then drop those elemnts when you move away from the tabs.

To overcome this performance challenge I stop dropping and adding the visual elemnts when tab is switched I just made it "collapsed".

Though now the tree is huge but it should not hit performance.

Are you aware of any performance if you have large visual tree with collapsed elemnts .Is it better or worse or same as those collapsed elements not in the tree.


ssrs moved rdl files from dev server to test server but its not working


Hi All,

I have developed 5 reports in dev box.After testing those i have saved the rdl files in a shared loacation.I told the Test team guys to copy the rdl files from that shared loacation and perform testing those reports on test box.But they are not able to do it.The reports are not running.they are throwing errors.I have one shared datasource for all those 5 reports.The reportserver for dev box is sqldev05 and test box is sqltest05.

What are all the steps needed to be implemented by test team so that reports will run succesfully in test box.

Thanks in Advance!!


How to unit test C# Web Service with Visual Studio 2010 ultimate


I have webservice running, how to test those web methods using the Test features of Visual Studio 2010.

As with normal web reference i am not able to create the classes and call the webmethods inside the test class.

Test-SPContentDatabase isn't working


I have an SPS2010 beta farm up and running.  I wanted to use Test-SPContentDatabase against another non-related farm (but in the same domain, no firewalls in place) but every time I try to run Test-SPContentDatabase -Namedatabasename -WebApplication Url -ServerInstance RemoteSqlServerName , I get "Cannot find an SPWebApplication object with Name, Id, or Url:Url ".

Thoughts on what I'm missing?  The user account running the command has sa/domain admin privs and PS is being run while elevated.


Visual Web Parts - programmatically change Web Part Title not working



I have four custom made Web Parts (based on the Visual Web Part template) that show a filtered set of data from various lists. These work just fine on my front page (which is a Publishing enabled page/site). Each Web Part has some functionality for setting a date filter on the set of data. Now, on every load I generate a string which tells what the current filter is (default filter, custom set date filter +++) and set this string to the Web Part's Title. This text then shows up in the Web Part's header. All this works just fine on the front page.
However, I also have a few sub sites that are based on either the Blank Site or a Team Site and on these sites setting the Web Part's Title property doesn't work. Well, it works, but doesn't get rendered. If I do a "Edit page" or go to one of the Web Part's properties, all the Web Parts' headers get updated to the correct text. But, the next time I load the page, it's back to some old value. 

I dont' get it! Does anyone know what might be causing this?


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend