wpf

Resources to read about Databinding causing memory leaks in WPF?

My wpf app is eating memory every time the ItemsSource of a TreeView is replaced (I simply construct a new object and assign it to the bound property). Furthermore the memory hoarding only occurs when I use a DataTemplate that is used in other ItemControls too. When I remove the DataTemplate the Treeview reverts to displaying the ToStri...

Raising WPF MouseLeftButtonDownEvent event

Hi, I am trying ot raise a MouseLeftButtonDownEvent by bubbling it up the Visual tree with the following code. MouseButtonEventArgs args = new MouseButtonEventArgs(Mouse.PrimaryDevice,0, MouseButton.Left); args.RoutedEvent = UIElement.MouseLeftButtonDownEvent; args.Source = this; RaiseE...

Using LINQ to Entity results with MVVM

I am getting started with Entity Framework using EF4 in VS 2010 RC. So far, I have done some simple console apps where I create an EDM, query it using LINQ to Entities, and output the results to the console. Now I am building a demo WPF app to learn how to integrate EF4 with WPF. I use MVVM in my WPF apps, where each view (more or less)...

Change property depending on property in other control - WPF

I want to use some kind of trigger to change a button in my window to IsEnabled = False when the textbox property Validation.HasErrors of my textbox is True. Can I do this with Triggers of some kind on the Button? If yes, some example would be nice! ...

WPF UserControl Binding Problem

I have the following user control that is embedded within another user control. <UserControl.Resources> <DataTemplate x:Key="ContextsTemplate"> <Label Margin="10,0,20,0" Content="{Binding Name}"/> </DataTemplate> </UserControl.Resources> <ItemsControl Name="Contexts" Background="Transparent" ...

Resize window with Visual State Manager

Hi guys, I'm looking for a way to resize the window when a button is clicked, the reason for this is that I want the user to think that the window is morphing into another window. Whenever I do resize the window in VSM, it just shows an exception and stacktrace leading to a bunch of errors, so is there a way to accomplish what I'm tryi...

Hmm... "add as link"ed images don't show up at runtime.

Sorry guys, I posted this earlier today where my "add as link"ed images were giving me a design-time error. I got assistance with that and now my code compiles, but now the images don't even appear when my application runs. Just for giggles, I changed the Build Action for the images, and nothing made a difference. Is there anything I ...

Can someone please explain what Child.Measure(availableSize) does in silverlight?

protected override Size MeasureOverride(Size availableSize) { foreach (UIElement child in Children) { child.Measure(availableSize); //you get the desired size after } } So for brevity i cut the code short, but i am having trouble understanding why in some example they pass...

set button datacontext to multiple elements

I've got a button that I need to be disabled when validation errors occur in my window. The items on which these errors can occur are all textboxes. I've bound my Button's datacontext as such: DataContext="{Binding ElementName=txtEmail}" Now with this, I can set the button style to disabled when validation errors occur in the email...

Testing a Gui-heavy WPF application.

We (my colleagues) have a messy 12 y.o. mature app that is GUI-based, and the current plan is to add new dialogs & other GUI in WPF, as well as replace some of the older dialogs in WPF as well. At the same time we wish to be able to test that Monster - GUI automation in a maintainable way. Some challenges: The application is massive. I...

I need to rollup an expander AND the stackpanel object it sits on in the window

Here is the code I have and wondered how I could completely rollup the stack, expander and objects within it to push all objects below it to take up the space left after rolling up the upper stack and objects. My current code is below: <Grid> <StackPanel Margin="8,8,0,0" VerticalAlignment="Top" Height="225"> <Expander Header="Expand...

Question on MVVM pattern on WPF ?

I have a user control let say UC1 . This user control have viewmodel UC1_vm. In the usercontrol UC1 I have a canvas in which drawing curve logic is implemented. This drawing curve logic is based on the data points property in the view model ( UC1_vm). The data points property inside the view model change with different condition. The...

How to set the font of child control inside the group box?

When I set different font to Group box the child controls also set to the font of group box. I have to set each child control with different font property. Like I have to set child control Font property to <GroupBox Font Size = "14"> <Label FontWeight"Normal" ,Font Size ="8"/> <TextBox FontWeight"Normal" ,Font Size ="8"/> </GroupBox...

WPF create a list of controls that can be scrolled via the mouse but still remain functional

I have a list of controls that I am displaying via a WrapPanel and it horizontally oriented. I have implemented a "Click and Drag" scrolling technique so that the user scrolls with the mouse via clicking and dragging. Like so: <Canvas x:Name="ParentCanvas" PreviewMouseDown="Canvas_MouseDown" MouseMove="Canvas_MouseMove"> <WrapPanel>...

WPF Radiobutton equivalent

What is the WPF equivalent for WinForms radio button CheckedChanged? I have your basic 2 radio button set up, where when one is selected a textbox is enabled and when the other is selected it is disabled. For the time being I was using RadioButton_Checked, except, I set IsChecked true for one button in the xaml. When I reference the te...

How to handle One View with multiple ViewModel and fire different Commands?

Hi All, I have senario in which one view and view has binding with multiple ViewModel. Eg. One View displaying Phone Detail and ViewModel as per bellow: Phone basic features- PhoneViewModel, Phone Price Detail- PhoneSubscriptionViewModel, Phone Accessories- PhoneAccessoryViewModel For general properties- PhoneDetailViewModel I have...

Is it OK to use WPF assemblies in a web app?

I have an ASP.NET MVC 2 app targeting .NET 4 that needs to be able to resize images on the fly and write them to the response. I have code that does this and it works. I am using System.Drawing.dll. However, I want to enhance my code so that not only am I resizing the image, but I am dropping it from 24bpp down to 4bit grayscale. I cou...

WPF TextBlock Overflow Text to the Left

As background I have a very long ID that too long to display in the given area of the TextBlock. The interesting portion of the ID is the end, that is the rightmost portion. What I would like to do is have the TextBlock, rather than the text overflowing right and cutting off the rightmost portion, overflow left and cutoff the leftmost ...

Best Way to show Busy Bar In WPF Application

I have WPF Application where I have One main form and other user controls are shown in the main form as child form. I have to show Busy bar when I make Async call to data base. What is the best way to declare Busy bar object and then used in every child user control. Should I need to declare busy bar object in the main Form and then Used...

Deleting an Image that has been used by a WPF control

I would like to bind an Image to some kind of control an delete it later on. path = @"c:\somePath\somePic.jpg" FileInfo fi = new FileInfo(path); Uri uri = new Uri(fi.FullName, UriKind.Absolute); var img = new System.Windows.Controls.Image(); img.Source = new BitmapImage(uri); Now after this code I would like to delete the file : fi....