ixmx

Code snippets

Tag: WPF

WPF XAML xmlns: assembly not found problem


Solved by giving the custom Assembly a strong name or in other words sign the assembly.

  1. Goto Project/Properties/Signing
  2. Click “Sign the assembly” and add a key file to the assembly
  3. Rebuild the assembly and the designer will accept the namespace declaration without an error.

Reference

Remove Child Elements from WPF Panel


This Extension Method shows how to remove Rectangle elements from Panel container.
Many objects derive from Panel. There are six defined panel classes (Canvas, DockPanel, Grid, StackPanel, VirtualizingStackPanel, WrapPanel)


public static class MyExtentions
{
    public static void RemoveRectangles(this Panel panel)
    {
        var children = from UIElement c in panel.Children where c is Rectangle select c;
        foreach (UIElement u in children)
        {
            panel.Children.Remove(u);
        }
    }
}