wpf

How to capture a mouse click on an Item in a ListBox in WPF?

Hi ! I want to get notified when an item in a ListBox gets clicked by the mouse, whether it is already selected or not. I searched and found this: (http://kevin-berridge.blogspot.com/2008/06/wpf-listboxitem-double-click.html see the comments) private void AddDoubleClickEventStyle(ListBox listBox, MouseButtonEventHandler mouseButtonEve...

DirectX.Sound in WPF

I wish to play Tones in WPF from a sound card device (not system speaker). Im disappointed to find that apart from playing a beep or a wav file WPF does not have any native way to play simple sound frequencies. ie play(freq, duration); Looking into using DirectX DirectSound Ive hit a problem on how WPF using windows handles, as Direct X...

Please help - Memory Leak in WPF

I wrote a very simple newbie app with a 6-sided polyhedron (a "box") which rotates 180 degrees when I click a button. and then rotates back again on the next click. Every rotation grabs another 90MB and it doesn't let go until I close the app. The box is defined in the XAML. The Storyboard, DoubleAnimation and PropertyPath, etc, ar...

Making "global" hotkeys in WPF

I'm programming an application consisting of three usercontrols in an main window. In one of the usercontrols, there's a slider that needs to be controllable by keyboard input. The left arrow should decrease value, right button increase and so on. I have this work, but only when the slider has focus. If some other control has focus, I c...

How to dynamically change ConverterParameter (or any) property of a MultiBinding (or any other) resource at runtime?

Hi. i'm new to wpf and xaml. i find solutions of most of the problems (in other languages) by searching here n there or googling around but this one made me crazy. i searched a lot on google and browsed many forums, but it seems that this time i met with a real challenge! I have following code in Window.Resources: <my:NameConverter x:K...

Styling different levels of a WPF treeview differently?

I have a very flat-structured treeview with only two levels of items - the main ones, and one level of subitems. I am using WPF MVVM and would like a way to style the two levels differently, but have no idea how. I bind the treeview to an ObservableCollection in my ViewModel, and each element has one more ObservableCollection for the ne...

Setting a WPF ContextMenu's PlacementTarget property in XAML?

<Button Name="btnFoo" Content="Foo" > <Button.ContextMenu Placement="Bottom" PlacementTarget="btnFoo"> <MenuItem Header="Bar" /> </Button.ContextMenu> </Button> gives me a runtime error 'UIElement' type does not have a public TypeConverter class I also tried <Button Name="btnFoo" Content="Foo" > <Button.ContextMen...

wpf ContentPresenter wont enable/disable

Hi, I've overridden a ComboBox in order to add an extra button at the end of the combo - i'm using this to help navigate round my application. Its a M-V-VM App that has an Edit-Save/Cancel mechanism that disables or enables the controls depending on whether or not the user is in 'edit mode'. I wanted my navigation button to always be...

Initialize a WPF combo box in XAML?

Is there a way to set the initial value of a databound combo box in XAML? Here is my combo box: <ComboBox IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding Source={StaticResource NHibernateTypes}}" SelectedValue="{Binding ElementName=IdentifierPoperty, Path=PropertyType}" HorizontalAlignment="Stretch" Ve...

Unit testing functions relying on MouseEventArgs?

I am currently working on a project of mine which is a MSPaint-like WPF application. However I don't paint with pencil tools or something similar but with objects (Rectangle, Circle, Triangle etc.). I use Prism and the MVVM model to achieve testability and maintainability. I've now run into a problem. I have a CanvasView.xaml that's (as...

VirtualizingStackPanel + MVVM + multiple selection

I have implemented a selection pattern similar to the one described in this post using a ViewModel to store the IsSelected value, and by binding the ListViewItem.IsSelected to the ViewModel IsSelected. <ListView.ItemContainerStyle> <Style TargetType="{x:Type ListViewItem}"> <Setter Property="IsSelected" Value="{Binding Mode=...

WPF Focus Navigation Wrapping

Is there a way to force Focus Navigation (as controlled by the Tab key or MoveFocus method) to wrap inside a given container? I have included code which demonstrates this problem below. What is the easiest way to make Tab move focus from TextBox "Charlie" to TextBox "Able" (and visa-versa for Shift+Tab on TextBox "Able") rather than mo...

Bubbling RoutedEvent or RoutedCommand to a ViewModel

I've got a collection of ViewModels that are rendered as tabs using a style to pull out the relevant content to display on the tab: public class TabViewModel : DependencyObject { public object Content { get { return (object)GetValue(ContentProperty); } set { SetValue(ContentPropert...

WPF ToolBar Separator shrinks to nothing when inside a StackPanel

Given the very simple wpf app <Window x:Class="Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="800"> <Grid> <ToolBar Height="50" > <MenuItem Header="Test1" /> <MenuItem Hea...

Is MVVM an alternative to Expression Blend?

I'm sure this is a Noob question, but I've never worked with WPF before. Is MVVM an alternative to Expression Blend? ...

3D transformation WPF

I draw two spheres in 3d WPF which has points like Point3D(0,0,0) and Point3D(-1.0,1.0,2.0) with the radius is 0.10 Now i want to draw a Cylinder joining these spheres, the only thing i have for this is radius 0.02. I want to know how to calculate the 3d point, height, direction etc for this cylinder. I tried by finding the midpoint bt...

Window.FindName can't find Border element that I've named through an attached property

Hi, I've got a xaml of a window with an unnamed border control somewhere inside. The border control uses an attached property that I wrote and the attached property basically sets the border control's Name property to a known value, like "placeholder". After the window is loaded, it tries to find that border control through the name tha...

Wrapping parallel ItemsControls?

I have 2 ItemsControls parallel to each other. The first is a set of TextBlocks with Property names and the second is a set of TextBoxes with Property values. Property1 Value1 Property2 Value2 Property3 Value3 " " The list goes on very long in some cases. Is there a way to possibly break the columns at a certain poin...

Getting shift/ctrl/alt states from a mouse event?

In my WPF App, how do I get the state of the shift, ctrl and alt keys in my mouse event handler? I seem to remember in MFC you could get that information from the mouse event. Thanks! ...

Suggestions for third party WPF controls...

Which are the best third party WPF controls available in market currently? ...