Showing posts with label XAML. Show all posts
Showing posts with label XAML. Show all posts

August 26, 2013

Debugging WPF Controls at Design Time

Question:
- How to debug Visual Studio 2012 instance design-time
- Debug at Design Time in WPF
- WPF Debugging Design-Time Exceptions
- How to debug in design time
- Debugging a control at design time in ...
- Test DesignerProperties.GetIsInDesignMode in Design mode
- I want stop code in code under GetIsInDesignMode ...

Solution:
OK, Step with me with open eyes, It's so easy and fun
- Open another empty VS (we called NEW)
- In NEW visual studio go to Attach to Process...
- Find and select XDesProc.exe and click on Attach button
- Back to main VS and go to a xaml (UI) and do a somethings ;-)
when the somethings change you can find it in NEW visual studio.
It's so easy, yeap, Take enjoy :)


July 26, 2013

Prevent Show a UserControl in ToolBox

Problem:
- I don't want User Controls showing up in the toolbox
- How to put out a UserControl from Visual Studio ToolBox
- My user controls appear in tool box
- User control must not show in toolbox
- Prevent a base class from VS2012 toolbox

Solution:
Just Add these lines to top of your class.
PS: The first line is enough

[System.ComponentModel.DesignTimeVisible(false)]
[System.ComponentModel.ToolboxItem(false)]

July 24, 2013

Toolbox Icon For WPF Custom Control

Problem: 
- Displaying a custom Icon on the Toolbox for a Custom Control
- A Toolbox Icon for a WPF Control
- How to add a custom Toolbox icon to a WPF custom control In Visual Studio 2012
- Add a custom control icon to the tool box in VS2012

Solution:
I test more solutions but this solution helps me and it's simplest as i think so.
Just Add a picture file (not just bmp file) to a folder (not a specific folder) with these conditions
- Name: must be a full control name + icon + extension like below example
Structure: FullControlName.icon.ext
Sample Name: Project1.Control1.icon.png
Sample Name: WpfApplication1.Forlder1.CustomControl1.icon.bmp

- Right Click > Properties > Build Action > Embedded Resource (Just Embedded Resource no Resource or another one)


Test:
These icons just appear, when use of your DLL and in Design Time, visual studio just use of default icons.

- Go to ToolBox > RightClick > Choose Items... > WPF Components > Browse... > Add the DLL of your project and enjoy of ICON :-)


July 22, 2013

member is not valid because it does not have a qualifying type name

Error
'Property Name' member is not valid because it does not have a qualifying type name.


Solution
It's so simple, You must declare Type of property.
Just add the Namespace and class name before properties.

Sample
Before:
<Setter Property="Background" Value="{Binding Background}" />

After:
<Setter Property="Background" Value="{Binding amaControls:amaButton.Background}" />

August 20, 2012

DevExpress ChartControl Printing

Problem:
- How to print DevExpress ChartControl ...
- How to printing ChartControl
- Print of DXChart ....
- How to print of DevExpress WPF ChartControl
- How to print DevExpress ChartControl via SimpleLink (DXPrinting) ...
- Print Preview a WPF Chart and Show Its
- WPF Chart Control - Print of DevExpress DXCharts for WPF

Solution:
Yes, it's simple. just call below method with chart control ;-)
private void PrintChartControl(ChartControl chartControl, bool withPreview = true)
{
    /// Prepare Template
    var templateImage = new FrameworkElementFactory(typeof(ImageEdit));
    templateImage.SetBinding(ImageEdit.SourceProperty, new Binding("Content"));
    DataTemplate templateData = new DataTemplate() { VisualTree = templateImage };
    /// Prepare Simple Link
    SimpleLink simpleLink = new DevExpress.Xpf.Printing.SimpleLink();
    simpleLink.DetailCount = 1;
    simpleLink.DetailTemplate = templateData;
    simpleLink.CreateDetail += new EventHandler<CreateAreaEventArgs>((sl_s, sl_e) =>
    {
        DrawingVisual vDrawing = new DrawingVisual();
        DrawingContext context = vDrawing.RenderOpen();
        context.DrawRectangle(new VisualBrush(chartControl), null, new Rect(0, 0, chartControl.ActualWidth, chartControl.ActualHeight));
        context.Close();
        RenderTargetBitmap bmp = new RenderTargetBitmap((int)chartControl.ActualWidth, (int)chartControl.ActualHeight, 96, 96, PixelFormats.Pbgra32);
        bmp.Render(vDrawing);
        sl_e.Data = bmp;
    });
    simpleLink.Landscape = true;
    simpleLink.CreateDocument(true);
    if (withPreview == true)
    {
        simpleLink.ShowPrintPreviewDialog(this);
    }
    else
    {
        simpleLink.Print();
    }
}

August 11, 2012

The tag does not exist in XML namespace


Error:
The tag 'XXX' does not exist in XML namespace 'clr-namespace:YYY;assembly=YYY'. Line zz Position zz.


Solution:
I know, it's really weird, but the solution is simple. Just change
FROM:
xmlns:ZZZ="clr-namespace:YYY;assembly=YYY"
TO:
xmlns:ZZZ="clr-namespace:YYY;assembly="
leave empty value for assembly=