wpf

Does Prism (CAL) provide any way to bind a command to for example a MouseClick event?

Hi girls and guys! I recently looked into Prism (aka the Composite Application Library for WPF) and really like the way I can structure my apps with it. However there is one downside that I just couldn't resolve. Is it possible to bind a command (from a ViewModel for instance) to an Event (for example: RightMouseButtonDown) via Prism?...

How can I make a TextBox be a "password box" and display stars when using MVVM?

How can I do this in XAML: PSEUDO-CODE: <TextBox Text="{Binding Password}" Type="Password"/> so that the user sees stars or dots when he is typing in the password. I've tried various examples which suggest PasswordChar and PasswordBox but can't get these to work. e.g. I can do this as shown here: <PasswordBox Grid.Column="1" Grid....

Why Use Prism?

I am interested in making a decent WPF application which will be pretty huge. Someone suggested using PRISM which we are currently looking into. We might be using the MVVM pattern to implement this application. I saw some PRISM screencasts and it seems like PRISM is mainly used to inject the regions with different views. Is that the main...

Copying a databinding in code?

Hi, I'm trying to change the Mode property of a databinding in code, but because databindings can't be changed after being set, I'm getting exceptions thrown. I was thinking of just making a copy of the databinding and using that, but the Binding class doesn't seem to be cloneable. Is there still a way to do it? If the above is not pra...

ComboBox Selected Item in WPF

Hi, How to set the combobox selected item in xaml? I tried something doing like this <ComboBox x:Name="cmbProject" ItemsSource="{Binding Project}" DisplayMemberPath="Name" SelectedValuePath="Id" SelectedItem="{Binding Path=Project,Mode=TwoWay}" SelectedValue="{Binding Path=Id,Mode=OneWay}"/> The above code does ...

MVVM WPF ViewModels for Adding New Entity

My concept for MVVM in WPF is that we have a ViewModel for every Model in your application. This means that if we have Customer class (entity) then we will have CustomerViewModel. The CustomerViewModel will have all the properties which are necessary to represent a customer. The CustomerView usercontrol will be responsible for creating t...

Setting textBox.Text doesn't update bound twoway property?

Does it make sense that if the Text on a TextBox is databound to a property using the twoway mode and I set the Text to something, it should update the property? My property gets updated when I type inside the control, but not when I set the value in code. ...

Catching MediaPlayer Exceptions from WPF MediaElement Control

I'm playing video in a MediaElement in WPF. It's working 1000's of times, over and over again. Once in a blue moon (like once a week), I get a windows exception (you know the dialog Dr. Watson Crash??) that happens. The MediaElment doesn't expose an error, it just crashes and sits there with an ugly Crash report on the screen. If you ...

WPF - Custom Window not working

I am trying to start building a Custom Window in WPF. I thought I had all the starting pieces in place, but so far, all I get is a regular Window with black content. I assume this is because it's not recognizing my template as the default one for the control. Can you please let me know what I am missing? Here's my code: namespace BaseW...

Dependency Property WPF Always Returning NULL

I have a UserControl called SharpComboBox. I am using MVVM model to populate the SharpComboBox with Categories. For that I need to set the ItemsSource property. Here is the usage of the SharpComboBox control. <sharpControls:SharpComboBox ItemsSource="{Binding Path=Categories}" Grid.Column="1" Grid.Row="1" DisplayMemberPath="Title"> ...

Custom attached events in WPF

I might be getting the terminology wrong here, but I think I'm trying to create an attached event. In the Surface SDK, you can do things like: <Grid Background="{StaticResource WindowBackground}" x:Name="Foo" s:SurfaceFrameworkElement.ContactChanged="Foo_ContactChanged"/> I want to create a custom event for which a handler can be add...

Why won't my progress bar work?

I can't get my progress bar to work. Any help is much appreciated! Here's the code: <Window x:Class="BulkSAConfigureControl.BulkSaProgressBar" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Please Wait.." Height="60" Width="300" WindowStyle="ToolWindow" Re...

Enumerating the controls declared inside a datatemplate in code?

Is there a way to examine the contents of a DataTemplate in code? I want to list out the controls in a datatemplate, looking for a specific type. Thanks! ...

Create a WPF "control" that is run in an external process

I have a WPF app which contains a number of child controls. One of these controls hosts a third party library which underneath the covers runs some native code which throws access violations and crashes the application. Unfortunately removing the library is not an option. What I'd like to do is spin up a new windows process, host the t...

What is the best way to start an animation when a bound value changes?

This is a situation that comes up often: In the View, you have a control bound to a ViewModel property (backed by a INotifyPropertyChanged). For example: <TextBlock Text="{Binding Path=Subtotal}"/> When the property changes, you need to bring the user attention to the fact with some creative animation. How I can utilize the fact that...

Open another application's System Menu

I have a WPF TaskBar like application that i am developing for fun and i want to be able to open the System Menu for the application (that is in my custom taskbar) that i right click on, preserving any custom menu that the app might create (i.e. Google Chrome). I have the following code that works for a borderless window app i made previ...

How do You Create a Read-Only Dependency Property?

How do you create a read-only dependancy property? What are the best-practices for doing so? Specifically, what's stumping me the most is the fact that there's no implementation of DependencyObject.GetValue() that takes a System.Windows.DependencyPropertyKey as a parameter. System.Windows.DependencyProperty.RegisterReadOnly returns...

Lightweight validation framework for WPF using M-V-VM

In implementing M-V-VM in a project and following advice of Karl Shifflett about implementing a validation framework, but don't really want to use a full framework (like Ocean) only for the validation part. What validation framework do you recommend that works with the M-V-VM pattern? ...

WPF ListView grows wider in response to resizing column, but does not shrink back.

In the following .NET 3.5 XAML, if you drag the column width of the 'Day' column wider, the ListView nicely grows to account for this. If you then drag the column width narrower, however, the table stays the same size as it was. This same problem exists vertically, too. If some of your columns have word wrap, the table will get tall...

MVVM pattern, IDataErrorInfo and Binding to display error?

On MSDN Magazine it has a good article about MVVM and they are binding the validation error in the Xaml to Validation.ErrorTemplate="{x:Null}". I do not get it why and how they can display from the IDataErrorInfo the error? Anyone can light me on how to get the error message displayed to the screen with the MVVM approach? ...