wpf

How do I preview a Windows Media Encoder session in WPF?

This code works in a windows forms application (it shows the preview) but not in a WPF application. WMEncoder _encoder; WMEncDataView _preview; _encoder = new WMEncoder(); IWMEncSourceGroupCollection SrcGrpColl = _encoder.SourceGroupCollection; IWMEncSourceGroup2 sourceGroup = (IWMEncSourceGroup2)SrcGrpColl.Add("SG_1"); IWMEncVideoSour...

Parsing time without date in a TextBox

I'm working on a time sheet application, where I'd like the user to be able to enter times in TextBoxes, e.g.: 8 a or 8:00 a or the like, just like you can in Excel. Now if you enter a date in a TextBox and then use DateTime.TryParse, you can enter it in several formats (Jan 31, 2007; 1/31/2007; 31/1/2007; January 31, 2007; etc.) and .N...

WPF - Identifying a scroll event from a horizontal scrollbar?

If you have a ListView with both horizontal and vertical scroll bars. How do you tell which one a scroll event is coming from? ScrollBar.Scroll="xxx" doesn't seem to differentiate. ...

Can WPF User Control Detect MouseMovement when Mouse outside of UC Area

hey all, I'm writing a WPF app whereby usercontrols are being dynamically created programmatically in response to an event. The main window canvas has a grid, and i'm adding new columndefs and rowdefs, which contain the new user controls. I need these user controls to keep track of where the mouse is, so that they can respond to event...

WPF DocumentViewer doesn't release the XPS file

hello! I am working on a WPF application that opens and displays XPS documents. When the application closes, the specification is the application should delete the opened XPS document for clean up. However, when opening a certain XPS document, the application throws an exception that the file is still in use when it tries to delete it. ...

How can I raise an event from anywhere in my WPF application?

I have a base page, BasePage, that raises an event that displays messages to the user. Works great on all pages derived from BasePage. I want to do the same thing from user controls, but they don't inherit from BasePage. What I want is a central place that I can call from anywhere and in that code it will raise an event. Where is a ...

Opening a directory chooser in C#

I am writing a quick and dirty application that reads all the files from a given directory. I'm currently using the OpenFileDialog to choose a directory and just culling off the file name that it provides. It seems like there should be a way to just choose directories though, but in a quick browsing of MSDN I didn't find it. If you ...

DrawingVisual performance with Opacity=0

If I have a DrawingVisual in WPF with Opacity=0, is that enough for it not to be drawn? We have hundreds of DrawingVisuals on a Canvas, and are currently setting Opacity=0 on the visuals that are not to be displayed, and I wanted to make sure there is no rendering performance hit for rendering a DrawingVisual with Opacity=0. UPDATE: I h...

Is Dependency Injection possible with a WPF appliction?

I want to start using dependency injection in my WPF application, largely for better unit testability. My app is mostly constructed along the M-V-VM pattern. I'm looking at autofac for my IoC container, but I don't think that matters too much for this disucssion. Injecting a service into the start window seems straightforward, as I can...

What is Java's answer to WPF?

I'm mostly a .Net person at the moment, but I've been playing with Java some lately-- exploring what's out there. Now I'm looking for the Java equivalent for WPF. I know I could find an OpenGL library or two out there, but that's not really as rich or simple as the WPF system. ...

WPF Binding to Grid Column Width

I'm attempting to bind a DependancyProperty in one of my usercontrols to the Width property of a Column in a Grid. I have code similar to this: <Grid x:Name="MyGridName"> <Grid.ColumnDefinitions> <ColumnDefinition x:Name="TitleSection" Width="100" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> ...

How do I trigger a style change if DataContext is null or not using WPF

I have a page with several controls. The controls are bound to display values which they get from the page's DataContext. What I would like to do is display another look of the page should the DataContext be null. In some cases the controls of the page should display differently if "their" property is set or not. Is is possible to creat...

WPF: Problem with Checkbox when binding datatrigger to property "Ischecked".

I have a checkbox in GridViewColumn which i use for show/change database value. The click event for the checkbox is used for change value in the database. For handling the state of property "IsChecked" I'm using datatrigger and a setter, se xaml code below: <Style TargetType="CheckBox"> <Setter Property="IsEnabled" Value="True" /> ...

Using data binding to launch animations in WPF

I am trying to adapt a simple WPF application to use the Model-View-ViewModel pattern. On my page I have a couple of animations: <Page.Resources> <Storyboard x:Name="storyboardRight" x:Key="storyboardRight"> <DoubleAnimation x:Name="da3" Storyboard.TargetName="labelRight" Storyboard.TargetProperty="Opacity" From="0" To="1" D...

Is there a wizard control in WPF

Hi, Is there any wizard type control in WPF? I need a functionality where I can go forward and back and use tabs to select a particular item which will show the details of the nested items. I can use the TabControl control but the tab items are dynamic so I cannot nest the region inside the tab item. ...

WPF: Problem with binding values to ComboBox inside GridViewColumn

My Views dataContext is bounded to a presentationModel with two observableCollections Members. In the View I have one listView which ItemSource is bound to is the first observableCollection. In one of the LilstViews column I want to present values from the second obeservable Colletion in my presentationModel. I cant figure out how to get...

How do I keep aspect ratio on scalable, scrollable content in WPF?

I'm fairly new to WPF and I've come across a problem that seems a bit tricky to solve. Basically I want a 4x4 grid thats scalable but keeps a square (or any other arbitrary) aspect ratio. This actually seems quite tricky to do, which surprises me because I would imagine its a reasonably common requirement. I start with a Grid definiti...

How to align variable size controls inside the WrapPanel in WPF

Hi, I have a wrap panel that is dynamically populated with Label and TextBox control. The display will be something like this: Label 1 [textbox] Label 4 [textbox] Label 2 [textbox] Label 5 [textbox] Label 3 [textbox] and so on... How can I setup the wrap panel so that it displays the controls like above? Also the wind...

INotifyPropertyChanged vs. DependencyProperty in ViewModel

When implementing the ViewModel in a Model-View-ViewModel architecture WPF application there seem to be two major choices how to make it databindable. I have seen implementations that use DependencyProperty for properties the View is going to bind against and I have seen the ViewModel implementing INotifyPropertyChanged instead. My quest...

WPF: How can you add a new menuitem to a menu at runtime?

I have a simple WPF application with a menu. I need to add menu items dynamically at runtime. When I simply create a new menu item, and add it onto its parent MenuItem, it does not display in the menu, regardless of if UpdateLayout is called. What must happen to allow a menu to have additional items dynamically added at runtime? Note...