wpf

Force rendering of a WPF control in memory

Hello, I have the following code: void Test() { currentImage.Source = GetBitmap(); RenderTargetBitmap rtb = new RenderTargetBitmap(100, 100, 96.0, 96.0, PixelFormats.Default); rtb.Render(currentImage); } This code is supposed to render currentImage, which is an Image control in my xaml to a RenderTargetBitmap. It doesn't ...

General checklist of things that have to know when converting a WPF app to MVVM

Hi, I'm taking an vanilla WPF application and converting it to use the MVVM pattern. During my evaluation of the code, I made up a list of topics that I'd need to know about before converting the application. My list looks kinda like this: dynamically loading xaml (although this is specific to my app) binding xaml to view model comman...

How to make DockPanel fill available space

I'm trying the content of a shopping cart in an ItemsControl (ListBox). To do so, I've created the following data template: <DataTemplate x:Key="Templates.ShoppingCartProduct" DataType="{x:Type viewModel:ProductViewModel}"> <DockPanel HorizontalAlignment="Stretch"> <TextBlock DockPanel.Dock="Left" ...

Problem with TextBox Focus in WPF

Hi, I would like to set the focus on a textbox in my custom document content in WPF. I set all those focusable parameters to true. Still, the focus is not on the textbox. Any thought or comment ? So far, I've added these textbox.Focus(); textbox.SelectAll(); to the constructor of my WPF page. textbox is in a Canvas inside a DockPanel, ...

What is the 'isStroked' parameter in StreamGeometryContext.LineTo ?

I find "true to make the segment stroked when a Pen is used to render the segment; otherwise, false." to be an useless definition. ...

How to set WPF window's startup ClientSize?

I want to set my WPF window's initial client size. I'm not seeing a straightforward way to do this. Specifically, when my window opens, I want it to be sized just big enough for its contents to fit without needing scrollbars. But after it's shown, I want the window to be freely resizable (either larger or smaller). If I set Width and H...

How to ease the transition from WinForms to WPF

I'm working on a large Winforms application dealing with large amounts of data exposed through grids. I see us eventually moving completely to an M-V-VM & WPF implementation but now we're still closer to a ball-of-mud than anything resembling loose coupling. As we evolve toward cleaner separation of concerns, what are some specific patt...

Write WPF output to image file.

Hi, Is there a way I can write the output of WPF say a canvas to a image file, jpg or the like. I want to use WPF to create a background for me as I want to use the BitmapEffects for a rectangle and also radius the corners. I want to use the bitmap in a webpage. Is this possible? Malcolm ...

Calling a parametrized constructor from XAML

While using WPF i noticed that when i add a control to a xaml file, the default constructor is called. Is there a way to call a parametrized constructor. ...

Pushing read-only GUI properties back into ViewModel

I want to write a ViewModel that always knows the current state of some read-only dependency properties from the View. Specifically, my GUI contains a FlowDocumentPageViewer, which displays one page at a time from a FlowDocument. FlowDocumentPageViewer exposes two read-only dependency properties called CanGoToPreviousPage and CanGoToNex...

WPF Credits effect problem: StoryBoard to animate a StackPanel that extends the height of the window

This is my first WPF project. I'm trying to get a rolling credits effect with a bunch of banner-shaped PNG's stacked on top of each other vertically. My current approach is to have a bunch of images in a StackPanel. Each image is approx 1024x150, and there is about 30 images. They stack vertically. I start the StackPanel at 0,200, so ...

Multiselect WPF Listbox Make Multiple Selections With a Single Click

Hi, I have a databound multiselect listbox bound to a datatable. When I select a listboxitem I want some other listboxitems in the same listbox to be selected automatically. I want multiple items to be selected with a single click. How can i do that? I can't do it in SelectionChanged event because it leads to calling the same event again...

Read-only Run elements in a WPF RichTextBox?

I may be completely imagining this, but I could have sworn there was a way to make individual Run (or Parapgraph) elements in a RichTextBox read-only. I also could have sworn I tried a method for doing this out myself a few weeks ago and was satisfied with the results - I vaguely remember it looked something like this: <RichTextBox x:Na...

Transform XAML syntax from Shorthand to full syntax

Is there a tool or a simple way to transform XAML code from the shorthand syntax to the full syntax? For example: moving from something like: <_TextBox Text="{Binding Path=Formula.Production, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"> to <_TextBox> <_TextBox.Text> <Binding Path="Formula.NumCloses" Mode="TwoWay" Up...

Can I use it's own data source for rowheaders in WPF datagrid?

I mean - one source for all the data and another one - for rowheaders (of course, with different style). I know, that one can do the same thing for columnheaders, because each datagrid.column have it's own .header property, where I can put any control with it's own DataContext, for example. But what for rows? Of course, I can add one ext...

WPF position and dimensions wrong

Hey I'm currently using a semi-transparent WPF form with no border as a camera style device in a program of mine. However, when I access the position (top, left) and dimension (height, width) properties of the form, it would appear they are wrong. The top property reported to be roughly 26 pixels higher than it actually is in relation...

WPF Window LocationChanged ended

Hi everyone I have a WPF Window, and I want to determine when a user finishes moving a Window around on the desktop. I hooked up to the LocationChanged event and that's fine, but I can't figure out how to determine when the user stops moving the window (by releasing the left mouse button). There's no event to help me determine that, so...

Difference between TargetType="controlType" and TargetType="{x:Type controlType}"

In WPF you can set the TargetType to either the name of the type or you can set it to {x:Type nameOfType}. Does anyone know what the difference is? ...

How to set order for dependency properties Callback change methods?

Hi! I have many dependency properties in my WPF usercontrol and many of them are set directly in XAML. Among these are ItemsSource and Value (my custom properties). The problem is that initial Value selects a concrete item in ItemSource. But to achieve this, ItemsSource must be set first. While debugging I realized that ValueChangeCallb...

Resize ElementHost to size of the hosted Xmal UserControl

Hi, I would like an expanding panel in my Windows Forms app. I was having a look to see if this would be possible using the WPF Expander control. I've created a Xaml UserControl where I've inherited from Expander rather than UserControl. I have a trigger on the Expander for setting it's size. Is it possible to change the height of the ...