wpf

Global PreviewKeyDown handler vs local PreviewKeyDown handler

I have a PreviewKeyDown handler on my mainwindow which handles up and down keys so I can navigate with the keyboard between my controls. Now I have the problem that in some Textboxes I also want to use the up/down keys. This seems impossible because the other handler seems to swallow the keys first. Is it possible that when one of thes...

How do I make an ellipse blink?

I am trying to make a custom control in WPF. I want it to simulate the behavior of a LED that can blink. There are three states to the control: On, Off, and Blinking. I know how to set On and Off through the code behind, but this WPF animation stuff is just driving me nuts!!!! I cannot get anything to animate whatsoever. The plan is...

Reading an XML File create a UI

Hi, Below is a sample XML which I want to read and create a few GUIs based on these structures at runtime, (the basic idea is to read the fields from a XML file and create the screen for the user input). I have written some sample code which creats the screen at run time, however i am not sure how o do this when i wish to read the fiel...

How to use Path in a DrawingImage?

I have some paths defined that I would like to convert into DrawingImage resources but I must be missing something. i.e. I want to take something like this: <Path Stroke="DarkGoldenRod" StrokeThickness="3" Data="M 100,200 C 100,25 400,350 400,175 H 280" /> and use it with something like this: <DrawingImage x:Key='icon'> ...

WPF: Controlling ListBoxItem height inside wrap panel

Hi All, I have defined Wrap Panel as ListBox Items template <Setter Property="ItemsPanel"> <Setter.Value> <ItemsPanelTemplate> <WrapPanel /> </ItemsPanelTemplate> </Setter.Value> </Setter> I have 3 ListboxesItems per row My ListBoxItem expands when ...

Are IronPython or IronRuby well-suited for the MVVM pattern in WPF/Silverlight?

Hi all, I've been very happily using the Model-View-ViewModel (MVVM) pattern in WPF and Silverlight apps in combination with C#. Declarative XAML markup and data binding are invaluable - I just can't live without them. But, this talk by Harry Pierson on dynamic languages got me excited about learning a dynamic language, and I'd like to ...

How to program Multi Tab Task bar Preview like IE on Windows 7 in WPF?

Windows 7 has a new Task bar, and IE can display multiple tabs in the task bar previews, most of programs which does have not implemented this new api only shows one preview, I have an application where I have multiple tabs and I want to show each tab on this preview. Let me elabourate more on it, I know that every new window created ...

WPF: OnKeyDown() not being called for space key in control derived from WPF TextBox.

In a WPF application, I have a control that I have derived from TextBox like this: public class SelectableTextBlock : TextBox { protected override void OnKeyDown(KeyEventArgs e) { base.OnKeyDown(e); e.Handled = false; } } The OnKeyDown method is not called when entering a space into the TextBox, nor when hi...

Selecting a ListBoxItem when its inner ComboBox is focused

I have a DataTemplate that will be a templated ListBoxItem, this DataTemplate has a ComboBox in it which when it has focus I want the ListBoxItem that this template represents to become selected, this looks right to me. but sadly enough it doesn't work =( So the real question here is within a DataTemplate is it possible to get or set th...

WPF Data Bound Control, Detect SQL Table change

Im having a moment of stupidness. I have a Treeview control in WPF, that is displaying a list of Quotes, ie Quote#, Quote Name eg "Q#1000" "Server Quote" This treeview is bound to a collection of objects public ObservableCollection quoteitems = new ObservableCollection(); Which are loaded from a SQL database via an SQLDataReader whic...

What are WPF Preview Events?

I have been looking for descriptions of events "Preview**" like every element has events KeyDown and PreviewKeyDown. What is difference (not that one is attached event and one is not, the real conventional difference and programming way difference) In any class derived from Control, you can override both methods.. OnKeyDown and OnPrevie...

How to add a "type here" message to a WPF TextBox?

If the text box has no keyboard focus and no text, then show italic gray "type here" text "inside" it. How? What doesn't work: Setting the Text property - it messes up data binding. Overriding the template - it's messy and overridden already anyway. Preferably, I'd like the solution to be as much XAML and as little C# as possible. Pe...

WPF layout riddle

Say I've got two elements in a window. I'd like element A to fill all unused vertcial space and have always at least eg. 200px height. Element B will have few fixed sizes (expander) and it should be given the space it demands (but leaving at least 200px for A). If there is not enough free space in a window, B should be scrollable. That...

WPF Combobox DisplayMemberPath

Ok, I looked at other questions and didn't seem to get my answer so hopefully someone here can. Very simple question why does the DisplayMemberPath property not bind to the item? <ComboBox Grid.Row="1" Grid.Column="2" ItemsSource="{Binding PromptList}" DisplayMemberPath="{Binding Name}" SelectedItem="{Binding Prompt}"/> The trace ou...

Looking to build a WPF XBap with full trust, can a purchased certificate get past some of the security issues?

We are developing an application that needs to talk to some hardware (serial port) on the machine, and most of what we do is WPF and .net, so an xbap seems logical. My concern is with the certifcates. I have seen a bunch of people showing how to create and self sign applications, but then the user is required to install that to their m...

WPF MoveFocus() working on Vista, not XP

The following bit of code works on Vista as expected (focus is moved down the ListView), but on XP SP3 (with .Net 3.5 SP1 on both) it moves only between the first two items of the ListView. if (myListView.SelectedItem != null) { IInputElement orig = FocusManager.GetFocusedElement(this); FocusManager.SetFocusedElement(this, myLis...

How to get a Content control to present a data template for a selected field in a WPF gridview?

so I have the following definition for a DataGrid control: <Custom:DataGrid x:Name="dataGrid" ItemsSource="{Binding Units, Mode=Default}" AutoGenerateColumns="False"> and later in the same XAML document I have the following Content control: <ContentControl Content="{Binding SelectedUnitResults, Mode=TwoWay}"/> What I would like to ...

WPF Instantiate User control programmatically to render it as PNG

hey all, I want to instantiate a user control programmatically in a DLL to save it afterwards as PNG file. This is generally no problem with PngBitmapEncoder and RenderTargetBitmap. This are my questions: How do I instantiate the control? Simply with the new-operator? Do I have to instantiate it in an seperate thread? How do I force ...

Sorting Two Combo Boxes Differently in WPF

Hi, I have in a form two combo boxes that have the exact itemssource property. Both combo boxes need to be sorted, but in two different ways. One is sorted by the ID (numeric), the other one by Name(Alphabetic). Is it possible to do such a thing? Thanks ...

How can I set the MinHeight of a StackPanel to be the combined height of its contents?

I have a StackPanel with several CheckBox controls inside it. How do I prevent the StackPanel from shrinking and obscuring the CheckBox controls when the window is resized? <StackPanel Margin="12,89,12,62" Name="stackPanel1"> <CheckBox Name="chkOption1" Width="157" IsChecked="True" Margin="6">Do this thing</CheckBox> ...