wpf

Managing multiple WPF views in an application

So I've seen that a Navigation Service exists in WPF for maintaining a flow through an application. I'm not really in the market for the back and forward type functionality. I'm just looking for a good way to switch between Views when a button on a particular view is pressed. I'm using MVVM, so I'm not sure if I can let the App.xaml.c...

How can i determine if an existing Listbox entry was right clicked

I'm trying to determine if a user has right clicked on an existing listbox entry or the empty portion, to enable or disable context menuitems. In WinForms (for a datagridview) i was able to do var result = DGVTasks.HitTest(e.X, e.Y); bool existingRowSelected = result .Type == DataGridViewHitTestType.Cell; in a datagridview. Now in ...

WPF - Change the comparer for a ListBox

I have a list box that contains a list of WorkItems (from TFS). I want to add items to be selected, but it is failing to identify the items as the same. Here is my code public void SelectQueryResultItem(WorkItem item) { lstQueryResults.SelectedItems.Add(item); } This works great when the WorkItem passed in is fro...

WPF ComboBox DropDown using PlacementTarget

I have a ContentControl comprised from left to right of a Button, partition and a ComboBox. I want the ComboBox dropdown to line up with the left side of the control as opposed to the left side of the combobox. I received a method in code but I was wondering whether if it could be accomplished in xaml. This gives me the name of the con...

WPF- Catch the clicking of a button that was added to a style (ListBoxItem)

I have added a button to a template for a ListBoxItem. I want to know how to catch the click for the button (not selecting the ListboxItem). The button clicks just fine in the UI, but I can't seem to find out how to wire up code so I can catch it. I tried using: <EventSetter Event="Click" Handler="Button_Click"></EventSetter> but...

WPF - Updating DependencyProperty Metadata

What is the technical reason for not being able to update a DependencyProperty's metadata after it has already been set? If you try to do something similar to below it will generate an exception saying: Cannot change property metadata after it has been associated with a property. MyProperty.DefaultMetata.PropertyChangedCallback ...

How to trim whitespace from a data-bound XML element in WPF using XPath?

How can the whitespace at the start and end of the content of an XML element be removed when binding to the element using XPath in WPF? ...

WPF wmv/mpg files skipping and jumping

I am trying to play some WMV/MPG files using the MediaElement control and for some reason, the video files jump and skip while they are playing. I have played them on their own, outside of the WPF application and they seem to play ok, so why might this be? I do scale them so that they are smaller, could that be an issue? Also, if you ...

How to play a sound in WPF

Hi, I'm a novice C# programmer and am having trouble getting music to play in my WPF (Windows) application using VS 2008. This is a web app. What I think is happening is myMediaElementExample variable is empty at the time it is used to execute the "Play" method in the ExpenseReportPage.xaml.cs file. Right now this program builds, bu...

WPF - Binding in XAML to an object created in the code behind

Can an object created in the code (ie C#) be used for binding in the XAML? For example: public class MyForm { private MyComplexObject complexObject; public MyForm() { InitializeComponent(); } public OnButtonClick(object sender, RoutedEventArgs e) { complexObject = new MyComplexObject(); } }...

Euler (Tait-Bryan) to WPF Transformation3D. Is it possible

I'm trying to use WPF integrated 3D classes to rotate a WPF 3D model. I'm stuck. I'm looking for the 10 or so C# instructions which in pure 3D WPF would rotate a model based on Euler's angles as input (yaw, pitch, roll): RotateTransform3D myTransform = TheSolution (yaw, pitch, roll) I'd then use myTransform to rotation myModel (myMod...

WPF window pre-loading

When switching between windows in my full screen WPF app, if it is the first time the screen has been shown, The monitor will go black momentarily before the windows is displayed. This only happens the first time the window is shown. Is there a way to pre-load each window so this does not happen? This is what I've tried: myWindow.Show(...

WPF: listview with checkbox and textbox in the same column

I'd like to accomplish the following listview, which uses different controls in the same column. It has two columns: Name and Setting. The first row's entry in the Name column is "On/Off" and the Setting is a checkbox. The second row's Name is "Elevation" and its setting is a textbox. I want to be able to populate the listview prog...

Opacity is not getting applied in WPF PopupControl.

Popup popUpControl = new Popup(); popUpControl.PlacementTarget = this; popUpControl.StaysOpen = true; popUpControl.Child = new MyUserControl(); /// my user control popUpControl.Opacity = 0.5; // this code has no effect in the appearance of the popup popUpControl.IsOpen = true; how to do ? Thanks in advance. ...

Add User Settings at runtime in a c# application

I want to add new settings to the user.config at runtime for a C# application (WPF). These settings will be added by independant modules so I have no idea what they will be in advance. Most examples refer to: Configuration config = configurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); But this only allows you to acc...

How do I create a binding that involves some sort of formula?

As an example, if I have an element whose size I want to be twice the size of another element, how would I achieve this? An example would be the following, mirroredObject is the object that I want to use half of it's width for the width of the Border object. <Border Width="{Binding ActualWidth, ElementName=mirroredObject, Mode=Default}...

WPF alignment stretch

Can someone help me understand the WPF stretch alignment. I often run into issues where I want a control to fill an area but I never understand on what level I should put the VerticalAlignment="Stretch". Specially when UserControls are involved. I always solve the problem by trying different things or putting stretch on all levels but I...

Refresh / Update WPF controls like win forms

changing the text of a label (or sophisticatedly we can say a text-based progress bar). in winforms you just Invalidate / Update. But how to do this in WPF without using Background Threads. ??? ...

What strategy should be used for converting real world measurements to WPF units?

We have an application that will be reading real world dimensions from the DB in milimetres, these values will then be presented to the user in WPF. Currently I'm using the following strategy when reading objects from the data store by multiplying MilimetresPrWpfUnit in the following example. public const double MilimetresPerInch = 25.4...

WPF Datagrid Hyperlink Right Click

Hi, I have a datagrid which has one hyperlink column with the following code: <dg:DataGrid Style="{StaticResource DataGridStyle}" x:Name="movieGrid" ItemsSource="{Binding ElementName=This, Path=movieData}"> <dg:DataGrid.ContextMenu> <ContextMenu Name="cm"> <MenuItem Header="Copy" Click="CopyC...