wpf

WPF hot key firing without modifier

I have a WPF window, which contains a button called Cancel. Under ordinary circumstances I want a user to be able to press Alt+C to cancel their actions and close the program. As such, the button is captioned "_Cancel." Problem 1: During Window_Load, if I press C without modifiers, the Cancel_Clicked event fires, and the program close...

Disable a WPF button, but still swallow the click events

I have a button in my application which is bound to a command. This button sits inside another control which also reacts to mouseclicks. When the button is enabled I get the behaviour that I expect - click on the button and the command is triggered, click outside the button but inside the container control and that is triggered instead. ...

WPF DropShadowEffect Causing Blurriness

I've observed that applying a DropShadowEffect to a UIElement sporadically causes the UIElement's content to blur a bit. It's a pretty nasty effect: it can cause a photograph to look out of focus or worse- make an entire 'popup' region completely illegible. I haven't seen anyone else complaining about this, so my inclination is to think...

WPF - Problems overwriting (re-saving) image when it was set as image source.

Good day all, I am having some trouble with image permissions. I am loading an image from file, resizing it and then saving it out to another folder. I am then displaying this like so: uriSource = new Uri(Combine(imagesDirectoryTemp, generatedFileName), UriKind.Absolute); imgAsset.Source = new BitmapImage(uriSource); This i...

Slider and Label/Textblock control interaction - WPF

I have a slider and a label control. The text is displayed in the label (few paragraphs). I need to show only 3 words at a time.Every 1 second, move to the next set of 3 words. The slider is used to select the number of words that can be seen at once. So a user can increase it to say 10 and now every 1 second, a set of 10 words need to...

WPF Style Hierarchy?

I may have missed something obvious with WPF, but is it possible to create styles that work hierarchically with the targeted control's child controls? To better explain, think of how CSS works to style HTML. You can hierarchically target controls with CSS via selectors: div > span em { color: blue; } ul.class > li ul li { displa...

WPF - DataTemplate binding to static member

I have a class with a boolean static property called CanSeePhotos and this should control the visibility of pictures in my DataTemplate. For debugging purposes I am binding "CanSeePhotos" to a text block in the DataTemplate. What I would like to do is: InitializeComponent() Set CanSeePhotos based on the logged-in user Load data and s...

New Window Opens Under Current

I have a window that I'm building in code, and showing: Window wndViewer = new Window(); wndViewer.Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0xFF, 0x31, 0x31, 0x31)); wndViewer.WindowState = WindowState.Maximized; wndViewer.Width = 1024; wndViewer.Height = 768; Grid grd = new Grid(); wndViewer.Title = "<Remo...

wpf create a textbox with a button for openfiledialog

Hi, I'm using a datatemplate for a type that has got a property which is the file address.I need to create a textbox with a button which will open an openFileDialog and then insert the selected file address into the textbox I wanna know what's the best way for creating the textbox and the button next to it which will show the openfiledia...

WPF - How To Tell What Raised The ComboBox_SelectionChanged Event

Is there any way to tell how the ComboBox_SelectionChanged event was raised in WPF. That is, was the event raised as the result of a user interaction, or as the result of a change in the property it is bound to? ...

WPF ListBox getting item datacontext OnMouseOver

I currently have a view that contains a ListBox bound to a a collection of view models and a user control that I would like to bind to the current item that the mouse is over. How can I get the current highlighted item in the list and bind it to the user control using only XAML and code in the View Model? Edit: The following image migh...

Windows 7 touchscreen keyboard in a WPF app

I'm building a .NET 3.5 sp1 WPF app for use on Windows 7 - is there a way to place the touchscreen keyboard in my application? NOTE: In contrast to other similar questions I'm not looking to embed the keyboard in my app, I just want to start the keyboard and use it for text entry. ...

WPF: How do I set a UI Element's background property to null/nothing/default in XAML?

In code, I can set a UI element's background property to its default value by setting it to nothing/null, i.e. myControl.Background = Nothing But how do I do this in XAML? In particular, I'm doing this in a Storyboard: <Storyboard> <ColorAnimation Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)" ...

WPF: How do I set a background to default in a key frame of a color animation in XAML?

From this earlier question, I learned that I can set a background to its default color in a ColorAnimation with the following: <Storyboard> <ColorAnimation Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)" Duration="00:00:02.00" To="{x:Null}" /> </Storyboard> But how do I do this in a key ...

WPF ListView : Header styling

I want to have a ListView with columns and a particular style: The background for ALL column headers should be transparent except when the mouse is over in one of them. When this happends, the column's background in which the mouse is over should be yellow and all the color in the other columns should be, let's say, blue. I've tried ...

How do I disable the opening and closing animation of the DropDown of a ComboBox in WPF?

When I put a combobox in my WPF app, at runtime, when I click it, it rolls down the included items. After selection, it rolls the DropDown up again. Is it possible to prevent the rolling animation from happening? Instead I'ld like to just have it open and closed immediately. - Marc ...

Alternative Content for a Selected ComboBoxItem

I need to place a ComboBox in a place where I have very limited space. Is there any way to show content for the selected item in the ComboBox that is different than the content that is displayed for the item in the ComboBox's Popup? As an example, Firefox does this with it's Site Search box in the top right of the browser. When you open...

WPF: Binding directly to a control

I need to bind a property of a UserControl directly to another control, rather than any specific property on that control. What's the best way to achieve this? I've tried various combinations of the Binding properties to no avail. For some context, the UserControl has a Next property that specifies which control is next in the navigatio...

Which would be the best 2D graphics library?

Okay, I bet this question might have been asked dozens of times before, but at the end of the day, I am still confused. I am working on a charting/plotting application. My application will also have WinForms controls. Edit: Actually it's little bit more than a simple charting application. I need to plot hundreds of symbols on the plot....

Create the same border type around all my controls

I tried to create my own Border class and then insert it in my controls but then it seems I cannot assign names to everything inside the borders: .. <my:ElementBorder> <StackPanel Name="ifBlock" Background="#E0E8FF" /> </my:ElementBorder> .. How can I get around this? Can I use templating somehow for that? EDIT: Sorry that I...