wpf

Set FontFamily and FontSize for the application in App.xaml

How can I set the FontFamily and FontSize for the application in App.xaml? ...

Preview of a window (Visualbrush) that is not visible

Hi. I've created a window dinamically that's is in memory but is not visible yet. In other window I want to show a little preview of this window. I'm triying using a visualbrush to achieve this, setting the visual property of the visualbrush. It works perfectly with a visible window, but if the window is not visible, the visualbrush do...

Where to find WPF Classic Theme as XAML?

I am creating some custom controls in WPF and need to therefore create the default control templates for them. To help in this process I would like to see the XAML of the control templates for the builtin controls as a reference. I can open up the PresentationFramework.Class dll into .NET Reflector but cannot find anything inside it of ...

Problem with combobox dropdown

Hi all, I have a problem regarding combobox dropdown. Once a dropdown is opened, if I want to move focus to other control (say a textbox), I need to click twice because on first click, the combo dropdown is closed and then on second click, the textbox gets focus. How should I fix this? Please help. ...

COMException when I use a Popup in WPF.

I have a very annoying exception which freeze my application thrown by WPF, when the content of this popup seems to have to much element. In the output windows I see approximatively 50 times this exception. 'System.Runtime.InteropServices.COMException' occurred in UIAutomationProvider.dll Then sometimes after the freeze I have th...

Creating video from WPF/Silverlight animation

I have a animation written in XAML. I need to create a video (AVI) from that animation. Is there a way to do that ? ...

Select Range of Text in WPF RichTextBox (FlowDocument) Programmatically

I have this WPF RichTextBox and I want to programmatically select a given range of letters/words and highlight it. I've tried this, but it doesn't work, probably because I'm not taking into account some hidden FlowDocument tags or similar. For example, I want to select letters 3-8 but 2-6 gets selected): var start = MyRichTextBox.Docume...

[WPF] Hide items with trigger in treeview

Hi, I've got a treeview, in which I use a HierarchicalDataTemplate. With this, I color my different items (all of the same type). With a click on a checkbox in the Page, I want to hide some of the items (with a certain Property). I've tested many code, but nothing works properly. I'm looking for answers ... Here's a sample of my code...

In WPF, Selecting ItemContainerStyle based on data bound content

In #WPF you have ItemTemplateSelectors. But, can you also select an ItemContainerStyle based on the datatype of a bound object? I am databinding a scatterview. I want to set some properties of the generated ScatterViewItems based on the object in their DataContext. A mechanism similar to ItemTemplateSelector for styles would be great. I...

Simple, quick way to get user input in WPF?

I recently started using C# and WPF for one of my projects. Is there a quick way of getting an input from the user? I have not been able to find one for WPF projects. I don't want have to create another window, add OK and Cancel buttons, and add event handlers for everything. I can do it, but I wanted to know a simpler way of doing it....

How can I create a simple 2D NURBS using XAML?

I need to create a spline with two endpoints and 'n' control points. As far as I am aware, a Bezier curve allows for only one control point, and a Bezier spline allows for two control points. However, I need to be able to add as many control points as I see fit, not limited to one or two. Here is an example of what I want to achieve, wi...

C# WPF How do I get a TreeViewItem from HierarchicalDataTemplate item?

I have the same problem as a previous question on this forum: previous thread I have a TreeView which uses a HierarchicalDataTemplate to bind its data. I need to get the TreeViewItem from the selected item, which is my own class. I have tried the solution given in the previous thread as well as modified versions of it. Nothing works....

How to prevent a new WPF form from stealing focus?

I have written a simple MSN-style program that will send and retrieve messages using WCF. The main form contains a Textbox to type in the message to be sent. In the background the application polls the server every few seconds for new messages. When a new message is received a new window is opened to display it. This has to be done on th...

WPF Documents: How to create paragraphs of "underlines" on which you can write answers to questionnaires

I am creating an application that is meant to print out forms meant to be filled in by humans writing on paper. These documents follow a question and answer style. Typically you have paragraphs with an "underline" style onto which a free-form answer of paragraph length can be written. How would you create this using WPF Documents? Here...

Unable to set initial value when databinding combobox to Dictionary<char,string>

I have a simple Dictionary defined as ResultOptions = new Dictionary<char, string> and my viewmodel has a public property ResultCode of type char. My XAML is as follow: <ComboBox ItemsSource="{Binding ResultOptions}" DisplayMemberPath="Value" SelectedValuePath="Key" ...

WPF Take screenshot from other thread than main thread

Hi, I have a thread that listens for commands to my WPF application. If the WPF Application gets a command to take a screenshot the task is handed over to a "screenshotService". I found som code to take the screenshot somewhere on the interweb, seems to work, but i havent thought it through....i cannot take this screenshot from another t...

Set text in multiple text boxes in cells in a grid in C# WPF

I'm new to C# and have set up a grid with 4 rows and 7 columns with a text box in each cell. I know how to manipulate the text boxes, but how can I iterate through the cells to access each text box? ...

Visual Studio 2008 WPF Problems

So I'm trying to learn WPF and my home and school setup in Visual Studio is totally different. I have no controls, no properties, no intellisense on the XAML page on my home computer. I looked around for this problem and I saw something with regedit, and I have the correct info there...still nothing though. Here are two print screens so...

Best way to reuse a dialog in WPF?

I have a WPF dialog with a couple user controls and some other standard controls. We have many uses for this dialog with specific tweaks. Right now this dialog manages all of the logic to tweak itself. I can't help but think there's gotta be a better way. I wish I could do something like this: Original dialog <dialog> <Control1> ...

Is it possible to Left-Align headers in a WPF TabControl?

Right now, I have a WPF window that looks like this: I'd like it to look like this (Photoshop doctored image): Is this possible without completely redoing the ControlTemplate? I tried messing with HorizontalAlignment, HorizontalContentAlignment, etc., but nothing I tried had the desired effect. Edit: If I try this solution (of...