Home » Windows OS

removing inherited effects, or routing events from one control to another.

Hi I'm not sure if this is the proper thread to put this question, but I'll give it a go anyway.

I have a SurfaceListBox with a control template that uses Effect.DropShadowEffect on it’s border. Some of the content is a third party control, that gets too much overhead using this effect. What I want is to only have this effect on the border of the listbox, and not it’s content. I’ve tried to set the BlurRadius etc to 0, but it doesn’t help on the performance.

Is there really no way to completely remove the inherited effects in WPF?

My hack solution to the problem was to pull the border out of the controltemplate, and then just drawing the listbox on top of it. This doesn’t look so good, as the content will not appear to be under the borders shadow. Which brings me to question number two, is there an elegant way to route events from my border/control to the listbox if I place it under the border/control? To be specific my listbox implements a surfacescrollviewer with a panel, and I want the listbox to receive drop, touchdown, touchmove and etc events.

Best regards,

Stian Farstad


1 Answer Found


Answer 1


Use the FrameworkPropertyMetadata.Inherits Property as shown bellow


PropertyMetadata propertyMetaData = EffectProperty.GetMetadata(border1);

            FrameworkPropertyMetadata fmMetadata = propertyMetaData as FrameworkPropertyMetadata;

            fmMetadata.Inherits = false;

All that you need is to render the effect  property of the given border  not inheritable by its childs. Of Corse you put  the right name of the border instead of the border1



The complexity resides in the simplicity


Does anybody know how to "inherit" or "intercept" a Parent Form's MouseDown from within a custom control?

I'm trying to create a custom control that lets me do Form Drag but the custom control must intercept the MouseDown event of its container (the parent Form). I think it has something to do with Delegates.

I would prefer not to write any code on the parent form. Just drop in the custom control, and when the Parent Form's MouseDown event is called, BaDaBing -the custom control intercepts/receives the Parent's MouseDown event.


I've sort of got this working now but I have to add code to the parent Form's MouseDown event which calls one of the custom controls functions. I prefer this step is handled automatically when the control is dropped on the Form by the user.

When we handle SSIS events using IDTSEvents callbacks as described here, will it in any way affect the event handlers already in that package? Eg will it override the existing package?

I don't know if routing an event is applicable here.  I have in one window a check box that hides/shows another window.  In the checked event I call the show method, hide method in the unchecked method.  In the closing event of the second window I set e.Cancel to true because I don't want to close it.  I want to actually hide the second window using the 'X'.  Is event routing useful for that or is there something more conventional like techniques used in WinForms?

I want the close event to fire the unchecked event of the checkbox so to have the show/hide methods being controlled by the checkbox of the main window



I have a WPF control that reacts to mouse events - how can I convert the contact down, contatc up & contact change events to correspond to the mouse events that the control listens for?

Is it possible to inherit a Windows User Control in WPF User Control. I mean a WinForms User control as a base class to a WPF User Control class (which would be of Xaml). Please let me know the steps or code snippet.

Thanks in advance.


I'm trying to install a couple of custom workflow task content types that are based on the standard workflow task type, but I want to remove some of the attributes defined on the std worfklow task type.  Per the MSDN online info you can use the <RemoveFieldRef/> tag in your XML content type definition file to remove such columns.  For some reason mine does not appear to work, however.  In addition to not removing the columns specified by the <RemoveFieldRef/> tags, it also does not create my custom "Comments" column -- It DOES create the custom "Respoinse" column.

The following are my XML definition files for the feature (which installs fine and the content types are created, but the columns I want to remove still show up).  Any idea what I'm missing to remove these columns from the custom types?  I pulled the IDs for the columns I want to remove from the std type definition XML under the 12-hive FEATURES folder

Type Definition File

<?xml version="1.0" encoding="utf-8"?>
<!-- See this blog for specifics: http://www.scribd.com/doc/2278897/Part-4-Custom-Workflow-Forms-TaskEdit-Form -->
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
		Name="MoreInfo Task"
		Description="Custom Task derived from standard SharePoint Task content type"
		  <FieldRef ID="{BD2DCA8A-EA92-4be9-B22F-A47779278832}" Name="_ResponseStatus" />
		  <FieldRef ID="{6C860AC7-5EE0-42fb-8836-F649634EB0D6}" Name="_UserComments" />
		  <RemoveFieldRef ID="{c15b34c3-ce7d-490a-b133-3f4de8801b76}" Name="Status" />
		  <RemoveFieldRef ID="{d2311440-1ed6-46ea-b46d-daa643dc3886}" Name="PercentComplete" />
		  <RemoveFieldRef ID="{64cd368d-2f95-4bfc-a1f9-8d4324ecb007}" Name="StartDate" />
		  <RemoveFieldRef ID="{cd21b4c2-6841-4f9e-a23a-738a65f99889}" Name="DueDate" />

Associated Column Definition File: 

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
	<Field ID="{BD2DCA8A-EA92-4be9-B22F-A47779278832}" 
			<CHOICE>Cancel Request</CHOICE>
	<Field ID="{6C860AC7-5EE0-42fb-8836-F649634EB0D6}" 


Any thoughts on what I may be missing?



I am trying to remove a permission from a folder by code.

The permission is inherited and that is why using the RemoveAccessRule method is not effective. From what i investigated the only possibility is to remove all inherited permissions using the SetAccessRuleProtection method. I am not interested in canceling the entire inheritance.

The interesting thing is that i achieved exactly that in the past by using ADsSecurity.dll in a vb6 component.

Is there any way to achieve the same using .net ?

This is my .net code:





void RemoveAcl(string path, string identity, FileSystemRights fileSystemRights, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, AccessControlType accessControlType)




FileSystemAccessRule fsar = newFileSystemAccessRule(identity, fileSystemRights, inheritanceFlags, propagationFlags, accessControlType);



DirectoryInfo dInfo = newDirectoryInfo(path);



// Get a DirectorySecurity object that represents the



// current security settings.



DirectorySecurity dSecurity = dInfo.GetAccessControl();



// Add the FileSystemAccessRule to the security settings.




And this is the old vb code:


Sub RemovePermmission(strPath As String, strUser As String)
Dim sec As New ADsSecurity
Dim sd As IADsSecurityDescriptor
Dim dacl As IADsAccessControlList
Dim ace As IADsAccessControlEntry

Set sd = sec.GetSecurityDescriptor("FILE://" & strPath)
Set dacl = sd.DiscretionaryAcl

'----Show the ACEs in the DACL----
For Each ace In dacl
    Debug.Print ace.Trustee
    Debug.Print ace.AccessMask
    Debug.Print ace.AceType
    If LCase(ace.Trustee) = LCase(strUser) Then
        dacl.RemoveAce ace
    End If
sd.DiscretionaryAcl = dacl
sec.SetSecurityDescriptor sd

Set sd = Nothing
Set sec = Nothing
Set dacl = Nothing
Set ace = Nothing

End Sub




My friend removed "Route" from the "manage content parts" menu under "blog" and now she can't access her admin panel.

Any suggestions on how to change it back? (:



hello friends!

ive asked this question here http://stackoverflow.com/questions/3967333/removing-specific-routes-from-asp-net-4-routestable but have not yet recieved a workable solution

the problem is that i need to remove only specific routes from the routetable and then add them back (with some changes). I do not want to clear the whole collection.

heres my code

For Each r In RouteTable.Routes
If CType(r, Route).DataTokens("ConfigID") = ConfigID Then RouteTable.Routes.Remove(r)

the problem is, as soon as the first route is removed, the following error is thrown:

Collection was modified; enumeration operation may not execute

so how can i get around this error? or is there a better way to remove routes?

Thank you very very much for your time and help!


I am developing a Windows application in C# in Visual Studio 2008 (on an XP Version 2002 Service Pack 3 computer) that must look and behave like an existing MS-DOS application. In order to make the window borders look like the existing window borders I have derived a new GroupBox control from the Windows.Forms.Groupbox control. This control draws a border using 2 concentric rectangles and also allows the title to be aligned on the left, center or right.

The forms contain other Windows controls that look like MS-DOS text and I don't want the mouse to be able to select any of these controls. To prevent mouse interaction on the forms I have placed a Panel on the form, I make it cover the form setting the Dock property to Fill, bringing the panel to the front and make the panel transparent using the SetWindowLong function. There is no mouse interaction on the form as required but my group box is not being drawn. If I cover the form and then expose it, the groupbox can been seen.

I have been doing some experiments by having a standard .Net groupbox on the form and a smaller panel that covers part of a label, the .Net groupbox and part of my groupbox. When the application runs it shows the label, the .Net groupbox and the uncovered part of my groupbox. I have even commented out the OnPaint method in my groupbox class so that the .Net class should draw the control and part of my groupbox is still not drawn. That really puzzled me because I thought that it would behave like the standard Microsoft control.

any expected consequence if not using a static FileSystemWatcher OnCreated event handler ?


I'm very new to wpf so please bear with me. I'm using VS2010 and .NET 4

I've created two user controls, one of which is embedded in the other. Control #2 is declared in a canvas on Control #1, Control #1 contains a ToggleButton to control the visibility of the canvas, and on Control #1 I'm using animation effects to make the canvas (i.e. Control #2) appear and disappear. Looks quite slick.

Now, Control #2 is a kind of "picker" control, and I want it to contain "Ok" and "Cancel" buttons. I've added these buttons and also added a couple of Routed Events ("Ok" and "Cancel") to Control #2. The idea here was that the user hits Control #2's cancel button, Control #2 fires the routed event, Control #1 picks it up, sets the visibility ToggleButton, and Control #2 disappears.

This sounds quite a straightforward thing to do, but I'm having no joy at all in picking up the event in Control #1 and setting the ToggleButton's IsChecked.

(With the exception of creating the two routed events) I am deliberately trying to avoid doing this in code behind - I want to just use xaml if at all possible.

Can anyone offer any pointers? As I say I'm very new to wpf and am not even sure I'm tackling the problem in the correct way.

TIA, Pete


A colleague and I were chatting about routed events, and we came up with some things that didn't make a lot of sense.  Primarily, what is the purpose of a Direct event, and why are both LeftMouseButtonDown and PreviewLeftMouseButtonDown direct events as opposed to bubbling and tunneling respectively?

According to the documentation, the LeftMouseButtonDown (and preview) events appear to behave as bubbling and tunneling events, except that the event is raised and reraised as these events traverse the tree.  Since direct events can only be handled by the source of the event, it follows that any UIElement could handle a direct event since each one is raising the event and is also therefore the source.  (Unless reraising the event is different than raising?).  Why are these then not tunneling and bubbling like so many other similar events?

Neither my colleague nor I could come up with a use case in which we would ever create a custom event using a direct strategy (although we came up with some for tunneling and bubbling), yet LeftMouseButtonDown, one of the most common events (if not THE most common) is using this strategy.

Anyone have any ideas about the rational behind this?



In a form (say FormA) i have 2 events "Keyup" for the form and button_click event for the button. I call FormA from the main form with a showDialog, after this i call another form (say FormB), it also has the 2 events. In both the form the button_click event has the logic to close the form (this.close()).

Now when the FormA is opened the focus is on button, if the user presses "enter" button the button_click event is called which closes the form, the logic returns to the main form and the next line i.e. to open the FormB is executed. Now here is the wierd part, in FormB because there is a KeyUp event handler; just after instantiation of the form directly this event handler is called.

I guess this is being routed from FormA. Shouldnt the FormA's keyup event be closed as soon as the form is closed?


hi all,

we are having some weird issues with URL Routing in ASP.NET 3.5. 

We have a search box that does a search and redirects to a routed URL.

 When we search for the first time (aka Press a button that forces a postback) everythign works as expected.  we get:

1. BeginRequest event.

2. Determines Route

3. Calls Routehandler to match the route item to the actual destination page

4. Routes the url appropriately.

After you do one search successfully and try again it fails to call the BeginRequest event.  Because of this the routing data never gets called and so the url is never routed to its correct destination.   What is weirder still if we append a "/" (trailing slash) to the url after the initial postback it DOES work properly again. 

So our search route looks like this


entering a term and pressing the SEARCH button would yield a result url like this:



Going back (after 1 successful search) you then need to use this url or else BeginRequest will never fire:

mydomain.com/Search/ < (note the extra "/" at the end)


Anyone have an idea as to why the BeginRequest event never fires unless the slash is appended?









 I want to set item level permission in a library. Therefore I developed an itemceiver that should catch new items in that library. My problem: no event is fired (I tried ItemAdding, ItemAdded, ItemUpdating, Itemupdating, ItemCheckingIn, ItemCheckedIn) . All items get into the library through routing, that means, the item is first stored in a dropofflibrary, than routed in my library where I want to set the permission. Probably the events are not fired by routing.The events are fired correctly, when I update or check in an item as soon as they are edited in my library.

Is there a way to set item level permission when routing is used?

Many thanks in advanced.





 I want to set item level permission in a library. Therefore I developed an itemceiver that should catch new items in that library. My problem: no event is fired (I tried ItemAdding, ItemAdded, ItemUpdating, Itemupdating, ItemCheckingIn, ItemCheckedIn) . All items get into the library through routing, that means, the item is first stored in a dropofflibrary, than routed in my library where I want to set the permission. Probably the events are not fired by routing.The events are fired correctly, when I update or check in an item as soon as they are edited in my library.

Is there a way to set item level permission when routing is used?

Many thanks in advanced.




Does anyone know if the Blur class is supported in Office - meaning, does it change the results in Open XML documents? I've tried even manually editing in PowerPoint both a blipFill as well as a buBlip and it doesn't have any real effect.  

<a:blip r:embed="rId2" cstate="print">
  <a:blur rad="270000" grow="1"/>

In the case of a buBlip, nothing happens. In the case of a blipFill, the image just shows as 100% transparent.

Anyone know if it is supported in PowerPoint and if so, why it doesn't really do anything?


Hi All,

Recently, I tried to get my Web Service class to inherit from a custom base class that inherits from System.Web.Services.WebMethod instead of the System.Web.Services.WebMethod directly.

However, I've been getting Error 500.

Public Class Service1
    Inherits BaseClass
    <System.Web.Services.WebMethod()> _
    Public Function GetSessionID() As String
        GetSessionID = Me.Session.SessionID
    End Function
End Class


public class BaseClass
    Inherits System.Web.Services.WebService

    public property Property1 as string
    public property Property2 as string

End Class


Please kindly assist.

Thank you in advance.

Warmest Regards,



Hi folks

I am trying to make use of inheritance to keep consistency in my user control appearance. I created a usercontrol to use as my base design, as a platform to link to a tab as a container. To this I added a few framing visual items like a header panel and some labels.

I then created another usercontrol that inherits from my base control, with the intention of adding the necessary items to this derived control to build it into a complete functional usercontrol that I can associate with a tab on my main form. I want to keep the visual appearance consistent across all similar derived controls. Then later if I change the design of the base form, this flows through to the derived controls.

The problem is that on my derived usercontrol, when I add items like buttons or a datagrid, and then instantiate the derived usercontrol, none of the new items (that are not already on the base usercontrol) appear.

What am I missing here? I thought this was the whole idea of inheriting from a base class?

Thanks for any advice.


<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure