wpf

Final steps in using MVVM to decouple GUI from business logic?

Just recently, I learned about using MVVM to decouple GUIs from the underlying model. I ended up learning as much as I could to convert my current application over to MVVM, and was largely successful. Now I need to figure out how to actually take a GUI generated in Blend and use it in place of my current GUI, which was designed in Visu...

WPF - Generate BitmapSource from Over state of a button

I can generate a BitmapSource from a button fine, however it always is just the image of the normal state of the button. I want to be able to generate a BitmapSource of the over state of a button. I tried calling VisualStateManager.GoToState((FrameworkElement)target, "MouseOver", true); before calling my code to generate the BitmapSour...

ContentControl render bug when using custom splash screen .Close() - what is going on?

I use a pretty basic ContentControl switching between different types of content: <ContentControl Content="{Binding MyContent}"> <ContentControl.Resources> <DataTemplate DataType="{x:Type local:Type1}"> <local:View1/> </DataTemplate> <DataTemplate DataType="{x:Type local:Type2}"> <loca...

MouseBinding overrides EventBindings in style

Hello I created a named style on an image, and in the style I set an EventBinding for the MouseDown event to a handler at the ResourceDictionary's code-behind, it worked good. When I use the image as the following: <Style TargetType="{x:Type Image}" x:Key="ImageStyle"> <EventSetter Event="MouseDown" Handler="Image_MouseDown"/> </S...

How to: A ListBox from two sources?

I am using EF with WPF. How should I create a ListBox that shows both Contacts and Persons? My question is rather how to retrieve it and create the CollcetionViewSource(s). I know I will have to use ItemTemplateSelector, that's less what I care, what I really care is the retrieval, but any tips on the representation will be welcommed as...

Clearing Textbox does not set binding to null

I am having difficulty setting an empty TextBox to null on an nullable DB Field. XAML <y:TextBox Text="{Binding Year1Cost, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, StringFormat=\{0:c\}}" Grid.Row="3" Grid...

Passing Generic lists to a WPF usercontrol

I want to create a usercontrol that takes lists of different objects. These objects would be assigned to the control at design time. Now I want to be able to use linq to object to sort this list inside the usercontrol. Can anyone give me any ideas as how to go about it? ...

Passing Generic lists to a WPF usercontrol

I want to create a usercontrol that takes lists of different objects. These objects would be assigned to the control at design time. Now I want to be able to use linq to object to sort this list inside the usercontrol. Can anyone give me any ideas as how to go about it? ...

Apply DataTemplate to type derived from FrameworkElement

I've got a list of custom "pages" in my app. Each page represents a different UI view. They have some simple properties, like a string title and an icon, but they also have a number of complex properties, consisting of controls to insert into the main toolbar, a main content area, custom statusbar panels, etc. The page type derives from ...

C#/WPF: How do I separate structure from styles like in web programming?

When programming for the web, you normally separate structure from style using a separation of HTML and CSS. How do I accomplish the same in a WPF project? All the examples I find use "inline" styling. Is it possible at all? Does it even make any sense in WPF? ...

How to fix selected Item in a collection control on a user control (using the MVVM implementation) in WPF

Hi, I hope someone can help me... Josh Smith did a great article on "WPF apps with the Model-View View-Model", and included in his article was the following code sample. If you download the code sample and run the app and view all customers, then select a company (e.g. 4th company), then click "Create new customer" (which will open a t...

WPF WebBrowser: How I do access progress and new window events

I'm building an a WPF app that uses the WebBrowser control. I'm struggling on a couple of points: How to get the current progress of a download from the control. The WinForms WebBrowser control raises ProgressChange events - how can I relicate this feature with the WPF variant? How to capture links that are trying to open in a new w...

Rotating a full 360 degrees in WPF 3D

Hi, I have a ModelVisual3D of a cube and I want to animate it to rotate around its axis for 360 degrees. I make a RoationTransform3D which I tell to rotate 360 but it doesn't rotate at all, also if you say 270 degrees it rotates only 90 degrees but in the opposite direction. I guess he computer calculates the "shortest path" of the rota...

Styling a UserControl in WPF from another assembly

Hi, I have a WPF user control defined in an application assembly. I'm trying to style the user control based on styles in another (skin or theme) assembly. I don't want the theme/skin assembly which contains the resourcedictionary with all the styles to reference the application assembly. Is there any way of doing this? E.g. WPFApp...

wpf flat button

How ma make a button flat style in wpf? I've tried BasedOn property but it does not work. ...

MediaElement fails after several plays.

Hi! I have a problem with MediaElement control. I've put six MediaElements on my form, then I start them and change played files by timer. After several times, these elements stop playing. Here is the sample XAML: <Grid> <Grid.RowDefinitions> <RowDefinition Height="*" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <Gri...

WPF DataGrid: how do I stop auto scrolling when a cell is clicked?

Problem: If my DataGrid is not entirely visible (horizontal & vertical scrollbars are showing) and I click on one of my cells that is partially visible, the grid auto-scrolls to bring that cell into view. I don't want this to happen. I've tried playing around with RequestBringIntoView, like this: private void DataGrid_RequestBringIntoVi...

How do I programmatically get the current Visual State of a WPF FrameworkElement?

How do I programmatically get the current Visual State of a WPF FrameworkElement? And by state I mean the states like "Normal", "MouseOver", "Disabled", etc. EDIT: Basically, I am changing the Visual state of a button with VisualStateManager.GoToState(e, "MouseOver", true);, and I want to know what state to change it back to after I am ...

How to wire up a progress indicator

I have a circular progress indicator. I'd like to add this progress bar to an application I'm working on but don't know how to wire it up correctly. In my app, I want to hit the "Process" button and have the progress bar displayed while the data is being processed. When the processing is complete, I want the progress bar to hide. I don...

In WPF, how do I get the true size of a FrameworkElement?

In WPF, how do I get the true size of a FrameworkElement, including the extra size that an effect such as a drop shadow adds? I have a button with a drop shadow on it. I am programmatically outputting it to a PNG file. I use ActualWidth and ActualHeight to get the size of the button, however this is the size of the button without the ...