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

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

ContextMenu does not work Sample from Msdn "How to:Implement ICommandSource"

Posted By:      Posted Date: October 22, 2010    Points: 0   Category :WPF


I am learning WPF , so I downloaded this sample from MSDN: http://msdn.microsoft.com/en-us/library/ms771361(VS.90).aspx

I cannot execute the command from the ContextMenu.

I think there is something wrong with the CommandParameter, but I do not understand what it is?

         <MenuItem Command="{x:Static custom:Window1.FontUpdateCommand}"
              Header="Update Font via Command"
              CommandParameter="{Binding ElementName=lbContextMnu,
                   StaticResource StringConverterResource}}">
          <ListBox Name="lbContextMnu">

View Complete Post

More Related Resource Links

MSDN sample Dllimport unable to load DLL



I tried out the sample described in MSDN "extern (C# reference)" (Example 2 and 3, the one which created an unmanaged dll called Cmdll.dll, then used it in cm.cs)

It doesn't work. I'm guessing path problem. Following is the error message.

Unhandled Exception: System.DllNotFoundException: Unable to load DLL 'Cmdll': Th
e specified module could not be found. (Exception from HRESULT: 0x8007007E)
   at MainClass.SampleMethod(Int32 x)
   at MainClass.Main()

The generated dll is in the same folder as the cm.exe. I copied the dll to the System32 folder. None works.

Any help appreciated.


Can't Get Changing ContextMenu to Work With ToolboxControl


Hi, I've got a project in which I'm trying to create a ToolboxContol that has a ContextMenu associated with it. Depending on the type of activity that is right-clicked, I want the menu to show different options. I figured that the easiest way to do this is to attach a handler to the ToolboxControl's PreviewMouseRightButtonDown event, in which I repopulate the menu with the appropriate options before it is shown.

There's one problem though. I can't find any way to determine which activity has been right-clicked. The ToolboxControl's SelectedItem activity tells you which one is selected, but right-clicking doesn't select an activity, and I can't find any way to identify the activity that is currently highlighted by mouse-over. Is there any way to do what I want here?

WPF ComboBox Style/Template example from MSDN doesnt work if "IsEnabled"=false?



I am using a customized look of the WPF combobox control with the help of the msdn Style and Combox Template example taken from here: http://msdn.microsoft.com/en-us/library/ms752094.aspx

I copied that code and I can use the control just fine, but as soon as you set the combobox attribute "IsEnabled" to false, you always get an error warning in Visual Studio 2010 Designer view with the following message:

'System.Windows.Media.Animation.ColorAnimationUsingKeyFrames' animation object cannot be used to animate property 'Foreground' because it is of incompatible type 'System.Windows.Media.Brush'.

Actually I have no idea on how to fix this error. Does anyone have an idea what is causing this error? Since its an msdn example everyone should encounter this error when disabling the control with this template example?

Thanks in advance for your help, kind regards,

Dispose sample in MSDN is buggy? incorrect?

 Dispose() Implements
Dispose(True )
GC.SuppressFinalize(Me )
End Sub

Well, the above is from a veebee sample but it applies to c# or anything else
as well. The point is,

should the above not call GC.SuppressFinalize BEFORE Dispose(true)?
Otherwise possibly race conditions between finalizer and the manual dispose?

RadioButton inside GridView, How to get it work as normal

Did you tried before to drag a RadioButton control inside a Gridivew templatefield, and then you attempt to select these RadioButtons , you will notice that the behavior of RadioButton control will be changed and it will work just like the behavior of checkbox control! the user will be able to select more than one radiobutton in the grid!

Abstract Factory Design Pattern (Sample in C# and VB .NET)

An abstract factory provides an interface for creating families of related objects without specifying their concrete classes. Sometimes one wants to construct an instance of one of a suite of classes, deciding between the classes at the time of instantiation. In order to avoid duplicating the decision making everywhere an instance is created, we need a mechanism for creating instances of related classes without necessarily knowing which will be instantiated.

MSDN Abstract Classes Link

MSDN Reference For Abstract Clases

Looking for guidance: wanting to work with AJAX architecture



I'm starting a small website that will be backed by a database, and will allow a small number of users to authenticate and select an entry in the database, and then view (and optionally update) a corresponding entry (think master-detail).

I have some flexibility in how I'll do this, but I'd really like to incorperate some newer AJAX style coding, eliminating some page postbacks. I think this is a great opportunity to learn the concepts well.

I'll probably go with an ASP.NET 4.0 site. From what I've seen there are MANY ways to go about this:

-WCF Data Services to expose the data, and consume in ASP.NET

-Page methods to expose the data, separate method to update the data

-I'd rather avoid the UpdatePanel because I'm really looking for a full hands-on approach, with learning client side scripting being an objective as well.

Beyond that, it seems that one can use jQuery to build clientside templates, but also one can use the ASP.NET AJAX template engine (in ASP.NET 4.0 I believe).

A concern I have: users should only be able to work with the data exposed via these endpoints if they are logged into the website. Hopefully I can somehow reuse the ASP.NET forms authentication cookie for this purpose. 

Well, I hope I've posted enough to a

animate effect work but the render items are messed up.


Hi all,

     I have a very unique problem, humm i think. I am using a jquery effect that animate bounce effect, i have a line in my javascript pageLoad function $("#UserBrowserInfoDIV").show('bounce'); - the effects run smoothly but what it does is mess up the bolded text in the div. I have try the items inside the div without bolding and it works fine and no render problem but when bolded the text that are bolded is quite messed up, and barely readable.

Please let me know is there anything else i can do i really would like use this effect.

P.S all the effect have the same render problem, and i am using ie8 under compatibility mode.





Looking for ASP.Net JQuery Post Sample


Hi, iam looking for a JQuery Post Sample, without reload of the current Page. I want on a webform enter a search text, onclick on the submit button i want get (webservice?) back clean html code that will be shown in a div tag
i found something like

<form id="formsearch" onsubmit="jQuery.ajax({type:'POST',dataType:'html',data:jQuery(this).serialize(),success:
function(data, textStatus){jQuery('#ajaxcontent').html(data);},beforeSend:function(XMLHttpRequest){$('#indicatorSearch').
show();},complete:function(XMLHttpRequest, textStatus){$('#indicatorSearch').hide();},
url:'/Search'}); return false;" action="/Search" method="post">

but how is the source asp.net (or webservice) build up?

can you give me some samples, how i can realize that with asp.net


Why getTreeNode does not work?



I try to run a  treeview example from msdn:


I also want to use code from


Here is my code:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register TagPrefix="mytree"
Assembly="Microsoft.Web.UI.WebControls" %>
 <script type="text/javascript" language="javascript">

     function xxx() {

         var myNode = treeview_one.getTreeNode(treeview_one.selectedNodeIndex);


<form id="myform" runat="server">
<mytree:treeview id="treeview_one"  runat="server" Child

Category attribute of user control property does not work correctly in categories tab.



I have a User Control (ascx) and a property which a want to display in my categories tab in Visual Studio in the category named "Styles".

[Category("Styles"), DefaultValue(""), Description("The value for formating something.")]
public String MyFormatProperty
set { /* the code for set */; }
get { /* the code for get */; }

And here is the problem: Actually I do not need a get, because I only have to set the property (write only property). But when I omit the get, the property is displayed in the "Misc" category in the categories tab in Visual Studio. Only when I code the get as well, then the property is displayed correctly in the "Styles" category in the categories tab in Visual Studio.

Does anybody know why? How can I display the category correctly only with set?

Thanks, S.

Editor's Note: Not Your Father's MSDN


Changes are coming to MSDN Magazine. They begin this month, with the unveiling of a number of new, monthly columns.

Keith Ward

MSDN Magazine February 2010

Team System: Customizing Work Items


Team Foundation Server's work iIem tracking system provides a number of advanced customization options.This article explores custom control support that lets you link to date, enhance the user experience, present data, and more.

Brian A. Randell

MSDN Magazine October 2009

Peer Fun: A Peer-To-Peer Work Processing App With WCF


We demonstrate creating a peer-to-peer processing platform where multiple players function together for a common purpose: getting your work done.

Matt Neely

MSDN Magazine June 2009

Patterns in Practice: The Unit Of Work Pattern And Persistence Ignorance


Jeremy Miller continues his discussion of persistence patterns by reviewing the Unit of Work design pattern and examining the issues around persistence ignorance.

Jeremy Miller

MSDN Magazine June 2009

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