For those new to message boards please try to follow a few simple rules when posting your question.
Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
Keep the subject line brief, but descriptive. eg "File Serialization problem"
Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
No advertising or soliciting.
We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
I am starting a new WPF project that's framework is going to be some sort of a tabbed view dashboard. In ASP I would use a master page with a tab control and a content page for each view. I am new to XAML and was hoping that someone knew of a basic article with example code to get me started. If anyone can point me in the right direction that would be great.
That looks OK (though I would prefer to copy the eventhandler and test that copy for null, but that should make a difference in rare cases only).
Where did you set the break point to step into that code? Was that action initiated by some change in the GUI?
We have a MindFusion.RealTimeCharting control that has been extensively modified by us, so talking to them probably won't help.
On a tab control I have User Control, and in that is the WinForms chart control. We want to create a report from the UI. A "Report" is an image that's created and opened in Windows Photo Viewer.
For the purposes of reporting I've written a class called PrintLib that takes the element you want to print, creates an image of it, and opens the Windows Photo Viewer with the image displayed.
The problem is that the actual contents of the chart, a Sine Wave, doesn't show up. To correct this we added a function to the chart control called 'GetPrintBitmap' which returns a DrawingVisual. We then have to call this in code to produce an image file which is the used to replace the image of the XAML element at runtime.
What we would like is to have this happen when the element is rendered. Basically, we need to force WPF to draw the Sine Wave from the WinForms control when the XAML element image is created.
What I have now does work, except that I have to call a function in the WinForms control to get the bitmap back. Here's what I do have:
The process starts here. Element is the outer control containing the User Control, which contains the WinForms control:
publicvoid Print(ItemsControl element)
ChartViewModel vm = ChartCollection;
RealTimeChart chart = vm.GetChart();
var dv = chart.GetPrintBitmap();
Here is the significant portion of the GenerateReport method:
publicstaticvoid GenerateReport(FrameworkElement element, DrawingVisual dv)
var width = (int)element.ActualWidth;
var mainImageName = string.Empty;
// If no WinForms image (the DrawingVisual) was passed in, then use the element
// that was tagged in the XML, otherwise use the passed in image as the main control
if (dv == null)
// Create the image of the element
mainImageName = CreateImageFromView(element, width);
mainImageName = DrawImage(dv, width, (int)element.ActualHeight);
privatestaticstring CreateImageFromView(FrameworkElement element, int width)
// Get the size of the Visual and its descendants.
var rect = VisualTreeHelper.GetDescendantBounds(element);
// Make a DrawingVisual to make a screen representation of the control.
var dv = new DrawingVisual();
// Fill a rectangle the same size as the control with a brush containing images of the control.
using (var ctx = dv.RenderOpen())
var brush = new VisualBrush(element);
ctx.DrawRectangle(brush, null, new Rect(rect.Size));
var height = (int)element.ActualHeight;
if (height == 0)
height = (int)element.Height;
if (height == 0)
var message = "UI Element height is 0 and is not valid";
return DrawImage(dv, width, height);
privatestaticstring DrawImage(DrawingVisual dv, int width, int height)
var rtb = new RenderTargetBitmap(width, height, 96, 96, PixelFormats.Pbgra32);
// Make a PNG encoder.
var encoder = new PngBitmapEncoder();
// Save the file.
var fileName = GetUniqueFileName("png");
using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None))
So essentiially we don't want to have create the DrawingVisual from the WinForms control in code. Is it possible to get WPF to render the WinForms control's contents when it renders the rest of it?
That's what my code already does, the problem is that the WinForms portion doesn't render as part of the WPF rendering process, so I'm calling a method on the WinForms control to return it's visible area as a bitmap, then replacing it ove the Winforms control.
I was hopeing there weas some way of forcing the WinForms control to render in the WPF rendering when the entire view is rendered.
Hello Every One, I have a Critical Problem in my WPF Ink Canvas. The Problem is , when i draw something on it using mouse move , it draws easily , but when my application run on other system, which have 1280*720 screen Resolution, that time Ink canvas draws shape outside the drawing area and the shape is not visible also.
my development Machine screen Resolution - 1680*1050 and when i run this application on low level Resolution Machines then Ink canvas drawing area expand and shapes are draw outside the canvas , and they are not visible also. I already tried the viewbox control, but i am not getting which i want.
Please solve this Problem as soon as possible if anyone have the solution of It.
I assumed you are doing the printing from the VM, forgot you have your odd printing method.
Still I would do it the same anyway, tab changed is bound to the VM and sets the active tab, Print command tells a VM property for each tab to print. Seems like a complete kludge but then you have a creative printing method!
Never underestimate the power of human stupidity
If the TabControls are implemented as a List of Lists of TabControls (or similar) in your AppComposer file (or App.xaml.cs, wherever you defined them), you could just go through said list(s) and look for the TabControl.SelectedTab property.
Once you get hold of the active/selected tab that way, you could notify it to print.
Just noticed that's about the same as what Mycroft suggested...but I would go for it as a first approach anyway
Does anyone know how to change the Spell Checking language of a WPF TextBox control to UK English.
I have tried setting Language="en-GB' and xml:lang="en-GB" as advised on all the websites - it does not work!
The software I am writing is literacy software (XAML Front end, C# Code Behind) for an education centre and needs to spell check in UK english
It seems really strange that WPF does not support UK English
- Windows does??
I have done this in a previous version of the software, but I think I implemented it as WinForms and maybe used a Word Interop for spell checking - but I cannot be sure that the users will have Word installed . . .
Please, Please, Help!
I read somewhere I can add a custom dictionary for UK English
anyone know where I can get one in .lex format
I have a file with all the differences between UK and US English - can I use this somehow