wpf

WPF Dynamic Image Loading into ResourceDictionary programmatically

Morning folks, I've been trying to cut out some of my app's processing when I stumbled upon a suggestion on SO to load all images into a resource dictionary via BitmapImages, then referencing them rather than loading an image each time. My problem is that I need to do this all programmatically, so: <BitmapImage x:Key="MyImageSource" Ur...

Looping through controls in WPF / Powershell

I am trying to loop through some controls in a Powershell / WPF application. Nothing fancy, just setting some text on a mouseEnter event. It works fine if I don't loop the code: $reader = New-Object System.Xml.XmlNodeReader $xaml $d = [Windows.Markup.XamlReader]::Load($reader) $d.FindName("GridOne").add_mouseEnter({ $d.Find...

Lookless controls with multiple children in properties/parts (+ theming)

I've created a custom control for MahTweets which simplifies/unifies the look of each update across the various social network updates we support. In theory it also simplifies how to theme everything, because we can just create a style for the lookless control. public class StatusUpdateView : Control { public static readonly Depende...

Recommended WPF Project Structure?

I'm a stickler for good Visual Studio Solution and Project structures. I'm about to start a WPF proof of concept piece of work. Can anyone recommend some WPF Project structures they have used and found worked well? Here http://drwpf.com/blog/2007/10/01/58/ They have one recommendation which I like: Root - Pages - Control...

problem with terminating the running program

i am making a wpf application in which there is a main window. normally when i close the main window the program used to terminate automatically but now it doesn't. altough the window is closed the program still seems to be running in visual studio. how can i fix this simple problem? ...

Thread safety, lists, binding and WPF

I have a WPF ListView that is bound to a collection (List<T>). It is currently updated from the current thread which works ok. I want to move the logic for updating the list into a thread and I see some potential issues regarding thread safety and the binding of the list. Can I be assured that the binding will not be updated unless I ...

WPF Error on Non-Development PC - XamlParse

I have an error very similar to the one addressed in this question. I am trying to deploy a small c#/Xaml utility on 6 work machines. 4 of the machines run the utility successfully and 2 do not. All machines are windows XP and have .Net frameworks 1-4 installed (my app is compiled against 4.0 and all machines have both client and extende...

How to make a specific GoToStateAction-with-DataTrigger run when element is loaded

I have a DataTemplate. It has two visual states - Expanded, Collapsed. I added 2 GoToStateAction-s. The first one goes to the Expanded state when a data context property becomes True, and the second one goes to the Collapsed state when that same property becomes False. A Checkbox is part of the template and bound to that property. So wh...

What is to FromFile and ToFile equivalent for BitmapImage?

The System.Drawing.Image has the easy to use methods for FromFile and ToFile. What is the equivalent for the Silverlight BitmapImage? I am trying to load and save a jpeg image as part of a unit test. The bytes must match exactly for it to pass. Here is my current guess: //I am not sure this is right private BitmapImage GetIm...

how to get the selected object in a listbox ---wpf

i have three listboxes, whose itemsSource is binded to a list, list and dictionary. i want to add the selected user and selected book to the dictionary with a command but i can't take the selected items. i am trying to obey the mvvm. i have a booklist and a userlist in my viewmodel which are binded to the given listboxes in my view. i co...

Dev resources for starting WPF Control Development

One of my upcoming projects needs a rather complex control (functionality wise) and I was wondering what, from experience, are good resources to look at / read? Any suggestions ...

WPF: Resizing a circle, keeping the center point instead of TopLeft?

Hi all, I'd like to resize a circle on my canvas with the help of a slider. This circle can be moved around on the canvas by some drag&drop stuff I did in code behind, so its position is not fixed. I have bound the slider's value to an ellipse's height and width. Unfortunately, when I use the slider, the circle gets resized with its to...

Triggers on a DataTemplate when data is updated

I've got a data template for a list box item similar to the one on this page... link I would like to take it a step further and do something to highlight the items when they change. For example, using the code in the link above, I would like to put a trigger to do something when Widget.Quantity changes. Maybe make the quiantity item (no...

What goes in the Main method for WPF / MVVM?

Doing my first MVVM WPF application. I expected to see a Main() method in the App.xaml (I'm used to Silverlight) but it isn't there. I added my own Main method. In Silverlight I then created a View linked to a ViewModel and set it as the RootVisual. How do I correctly open my first View Window in WPF? ...

Window transparency in WPF vs Winforms

Why is it that I have to set the WindowStyle property to None on a WPF form to get transparency, but in Winforms I can do it on any form, and retain borders, standard buttons, etc? Clearly the API supports this, so I'm not clear on what's special about WPF that would make this an issue. I'm guessing that WPF is jumping through some Dire...

How to detect that WPF window has been snapped in Windows 7

Windows 7 has the snapping feature which 'snaps' a window to the edges, and changes the one dimension of the window size to match the same dimension of the screen, and then choses another size for the other dimension. I want to detect that it has happened so that in my WindowStyle.None window with custom chrome, I can implement the pro...

Is it possible to have a solution that builds an XBAP and Standard Application as an output?

Hi all, Is it possible to have a project build that produces both a standard version of an application (standard as in just the exe and its required assemblies) and an XBAP version of the application? I have looked on the internet and read my books on WPF and I have not found a way to do this as of yet. Thanks for your time and I look ...

Define Background Color of Alternating TreeView Rows Based on Visibility

Is there a way in WPF to define the background of alternating visible rows? I've tried setting the AlternationCount property, but that restarts for every child node which gives a weird look. Ideally what I would like is to know what the visual index of a given node is. Only expanded nodes are counted. ...

How should I move a WPF Window using MVVM?

This is probably overkill on the MVVM pattern but it's new to me and I'm interested to see if it is possible. If I attach to the MouseMove event for a Window and do DragMove, I can move a bordeless window. Can I achieve this by some other method in MVVM or should I just accept adding this code to the Window's codebehind? ...

Why doesn't my WPF style work?

Trying to put a style in app.xaml. My app.xaml reads: <Application x:Class="TestApp.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt; <Application.Resources> <Style x:Key="TestStyle" TargetType="Button"> <Set...