Richard's Blog
Tuesday, 25 February 2014
Monday, 17 February 2014
#WINNING with C#: Weak Event Handlers
#WINNING with C#: Weak Event Handlers: Why would you need to use a Weak Event handler? Take a look at this example of normal events and handlers: Notice how the Console window i...
Tuesday, 21 January 2014
BindableApplicationBar - Button & MenuItem
A bindable ApplicationBar control wrapper for Windows Phone that allows specifying and updating the ApplicationBar properties by changing the properties of a view model instead of handling events in the code behind
BindableApplicationBar CodePlex Project
WP8 Appbar Management with AppBarUtils
BindableApplicationBar CodePlex Project
WP8 Appbar Management with AppBarUtils
Wednesday, 30 May 2012
Populate Treeview Recursively
The following code snippet demonstrates how to populate a tree view control by making use of a very simple recursive method and an interface:
Firstly, the interface:
Secondly, let's look at the method:
Okay, so that was a basic copy and paste job. To use the above code, we can do something like (obviously, this goes without saying, that the StructureResponse class that is used in the List<T> below, implements the IStructure interface):
And that's, that ...
Hope it helps!
Firstly, the interface:
/// <summary>
/// Structure Interface
/// </summary>
public interface IStructure
{
/// <summary>
/// Gets or sets the ID.
/// </summary>
/// <value>
/// The ID.
/// </value>
string ID { get; set; }
/// <summary>
/// Gets or sets the parent ID.
/// </summary>
/// <value>
/// The parent ID.
/// </value>
string ParentID { get; set; }
/// <summary>
/// Gets the display value.
/// </summary>
string DisplayValue { get; }
}
Secondly, let's look at the method:
/// <summary>
/// Binds the tree view.
/// </summary>
/// <param name="nodeCollection">The node collection.</param>
/// <param name="parentNode">The parent node.</param>
private void BindTreeview<T>(IEnumerable<T> nodeCollection, TreeNode parentNode)
where T : IStructure
{
var nodes = nodeCollection.Where(x => parentNode == null ? x.ParentID == null : x.ParentID == (((T)parentNode.Tag).ID));
foreach (var node in nodes)
{
TreeNode newNode = new TreeNode();
newNode.Text = node.DisplayValue;
newNode.Tag = node;
if (parentNode == null)
{
this.tViewProdStructure.Nodes.Add(newNode);
}
else
{
parentNode.Nodes.Add(newNode);
}
this.BindTreeview(nodeCollection, newNode);
}
}
Okay, so that was a basic copy and paste job. To use the above code, we can do something like (obviously, this goes without saying, that the StructureResponse class that is used in the List<T> below, implements the IStructure interface):
// get the structure based on the equipment ID and the serial number (from database)
List<StructureResponse> equipResultCollection = DataInterface.GetStructureFromDatabase(new StructureRequest(this.EquipmentID, this.SerialNumber));
try
{
// begin the update - this will suspend the UI
this.tViewProdStructure.BeginUpdate();
// build the tree view structure
this.BindTreeview(resultCollection, null);
}
finally
{
// resume UI responsiveness
this.tViewProdStructure.EndUpdate();
}
And that's, that ...
Hope it helps!
Wednesday, 11 May 2011
Signing an ActiveX control
The following tutorial demonstrates how to sign your ActiveX control: http://www.dreamincode.net/forums/topic/38890-activex-with-c%23/
Tuesday, 3 May 2011
Visual Studio 2010 SP1 - Issue with config file location
Struggling with VSTO installation after you installed SP1 for Visual Studio 2010? See this link. Basically you need to change some values the registry setup project. As explained here by one of Microsoft's developers:
You'll need to make the change in your deployment project, not in the .vsto or .manifest files. Specifically, you need to change the string written in the "Manifest" registry value. For example, the walkthrough in this article directs you to set the "Manifest" value to "[TARGETDIR]ExcelAddIn.vsto|vstolocal": http://msdn.microsoft.com/en-us/vsto/ff937654.aspx. To satisfy the new URI scheme requirement for Fast Path loading, you actually need to set the value to "file:///[TARGETDIR]ExcelAddIn.vsto|vstolocal".
This solved my problem...
You'll need to make the change in your deployment project, not in the .vsto or .manifest files. Specifically, you need to change the string written in the "Manifest" registry value. For example, the walkthrough in this article directs you to set the "Manifest" value to "[TARGETDIR]ExcelAddIn.vsto|vstolocal": http://msdn.microsoft.com/en-us/vsto/ff937654.aspx. To satisfy the new URI scheme requirement for Fast Path loading, you actually need to set the value to "file:///[TARGETDIR]ExcelAddIn.vsto|vstolocal".
This solved my problem...
Subscribe to:
Posts (Atom)