wpf

Convert ImageSource to BitmapImage - WPF

I'm using a class library that generates a large ImageSource, > 3000x3750 pixels. I would like to convert this ImageSource to BitmapImage so that I can take advantage of DecodePixelWidth or DecodePixelHeight instead of resizing it everytime this image is generated. I need to display this image for the user first, and most of the users h...

Building a MVVM 3D Editor Application -> Getting Mouse Position?

Hi, In my 3d editor application, I want to be able to click on and move a scene's entities (meshes, lights, cameras, etc). To do that, I imagine that I need to get the current mouse position relative to my Direct3d view and somehow give it to my ViewModel. How would I go about doing that, considering that my app is built with the MVVM p...

How can I easily add a WPF Converter item template to Visual Studio?

I find myself creating Converters often and would like to be able to: right-click on my Converters folder Add New Item... choose Converter Item Template I found these instructions but I can imagine that there are templates for standard files like WPF Converters already available somewhere, does anyone know of any? The following file...

Visual Studio 2008 WPF designer won't load my forms

I'm trying to see a form developed by someone else (ex-employee) in Visual Studio 2008 but keep running into the following error when I try and look at MainForm.xaml (it fails to load in the designer view): Error Could not create an instance of type 'NumericTextBox'. D:\MySolution\GUI\MainForm.xaml My solution is organised somethin...

How can I get a trigger to fire when the contents of a StackPanel changes?

The following code makes the contents of a StackPanel fade in when it is loaded (StackPanel.Loaded). What do I have to change to get the fade it to start when the contents of the StackPanel change, e.g. every time a message in the StackPanel changes I want it to fade in again? <Style x:Key="MessageStyle" TargetType="StackPanel"> <S...

Can't use "this" keyword or some objects in WPF Project (identifier expected)

I have a WPF project. When I add a class and a method, and write "this.", I get no intellisense. There is a message in the bottom tab of Visual Studio that an identifier is expected, but that doesn't make sense. Furthermore, I can't access some methods/objects. Take the following example: DbProviderFactory factory = DbProv...

WPF Convert Integer to Image without DB Binding

Using the following code, I'm retrieving a list of Integers from a DB and Converting them to Images of Flags <ComboBox Name="ComboBox1" ItemSource="{Binding Path=NumberList"> <ComboBox.ItemTemplate> <DataTemplate> <Image Source="{Binding Path=Numbers, Converter={StaticResource myValueFlagConverter}...

CS2000: Compiler initialization failed unexpectedly

I have a WPF .NET 3.5 SP1 application that is in use on at least hundreds if not thousands of machines at this point. The application stores a tree structure in XML that is loaded at startup. As soon as I try to load the xml via serialization, boom. It only happens on one end user machine. He has admin rights, plenty of disk space, m...

Can I do this in .Net and WPF?

Hi, We have a third party app that has VBA integrated into it. This all allow us to open a vb6 activeX Dll that contains a UI and we pass the apps instance to the vb6 dll. ' Instantiate the SMTree UI. Set oSMTree = CreateObject("SMTree.clsMain") ' Start it up. oSMTree.cMain Application Then in the VB6 app the main looks like: Publi...

How can I handle a Validation.Error in my ViewModel instead of my View's code behind?

I'm trying to get WPF validation to work within the MVVM pattern. In my View, I can validate a TextBox like this which gets handled by the code-behind method "HandleError", which works fine: <TextBox Width="200" Validation.Error="HandleError"> <TextBox.Text> <Binding Path="FirstName" NotifyOnValidation...

When does it make sense to abandon MVVM?

As I've been learning WPF, I've been concentrating on applying only the MVVM pattern to applications. However, I notice that for some functionality such as validation, it is difficult or impossible to remain true to the MVVM model. Many times simply sticking an x:Name on an element and changing it in code-behind event-handler solves the...

MVVM Tabcontrol change tab

I am developing an mvvm app with wpf. A requirement just got added on to block the user from changing tabs if a textbox has text. What is the best way to do this completely in the viewmodel? I don't know how to block a tabitem because there is no dependencyobject command in the tabcontrol to tie into, do i need to roll my own tabcontro...

A read-only CheckBox in C# WPF

Hi everyone, I am having a tricky problem, I want some slightly unusual behaviour from a checkbox and can't seem to figure it out. Any suggestions would be most welcome. The behaviour I want is: The CheckBox is enabled and ready for the user to click, IsChecked represents a bound boolean value stored in a data structure The user clic...

how do i get a wpf window to refresh?

I am building a simple roulette app. The player(UI) puts together a list of bets and submits them to the table object to be evaluated and paid out. I've got the code to work and the game process goes smoothly. The problem is that after a turn I can't get the player balance(textblock) or the betlist(listview) to update. Is there some ...

WPF Child element of a Canvas outside of rect bounds

I am creating a control where I am simulating a popup by using a canvas that contains a textbox and a grid container. The size of the canvas gets set to the size of the textbox and the textbox is positioned at 0,0 within the canvas. The Grid container is positoned at the y coordinate of the textbox and its visibility is set to Collapsed....

WPF Grid Items and Right Aligned Text

I have a WPF form where I'm trying to make a simple input form. Two labels, two textboxes, and a "submit" button. I have the layout pretty good, the only thing that I can't get is for my "Labels" to be right aligned inside their cells. I have tried both TextAlign="Right" and HorizontialAlign="Right", that moves the text ALL the way ov...

WPF - Drag from withing DataTemplate

I have a ListBox displaying employees with a DataTemplate - it looks very similar to this screenshot. I want to be able to click on the employee photo, drag it and drop it somewhere out of the ListBox. How can I do that? I am not sure how to capture the PreviewMouseLeftButtonDown event of the Image, since it's inside the DataTemplate. E...

Bindable LINQ (BLinq) in VB.NET

I cannot get Bindable LINQ to work with VB.NET for the life of me. How do I get the .AsBindable extention to appear? Sample code: Class TestList : Inherits Bindable.Linq.Collection.BindableCollection(Of TestItem) 'Some Helpers and stuff' End Class Class TestItem 'Some Properties' End Class Imagine I magically come up with a coll...

Is a DelegateCommand the same as an "Attached Behavior"?

I have been using the DelegateCommand found in the MVVM Visual Studio template at CodePlex. This works very nicely for having Views be able to execute commands on their ViewModel. I read somewhere that in MVVM "attached behaviors" should be used. As far as I can tell, "attached behaviors" are the same type of pattern as DelegateCommand ...

What exactly are "WPF services"?

Someone told me in an answer to a stackoverflow question that the "two big guns" for the MVVM pattern are 1) attached behaviors and 2) services. I assume he means "WPF services" a phrase which I found used in the following ways: PresentationFoundation.dll defines the WPF controls types, animation and multimedia support, data bindin...