wpf

Add collection or array to wpf resource dictionary

I've search high and low and can't find an answer to this. I have two questions How do you create an array or collection in XAML. I've got an array I want to stick in there and bind to a combo box. My first idea was to put an ItemsControl in a resource dictionary, but the ItemsSource of a combo box expects IEnumerable so that didn't...

How can I overlay one image onto another?

I would like to display an image composed of two images. I want image rectangle.png to show with image sticker.png on top of it with its left-hand corner at pixel 10, 10. Here is as far as I got, but how do I combine the images? Image image = new Image(); image.Source = new BitmapImage(new Uri(@"c:\test\rectangle.png")); image.Stretch...

WPF: Create your own screen-saver if your running application is 'idle'

Hi, Is there a way to create a window (similar to a screen-saver) that will be displayed once your running application is not 'interacting' (or being idle) with the user, meaning to say, no mouse movements happening on the application. Some of my friends suggested to use a Timer for this one. Any suggestion for a good head start? Thank...

How can I unattach an element from another element in the XAML tree?

In my Silverlight application, I load all the images I need at application start and store them in a dictionary. Then as I need them I pick them out of the dictionary and attach them in XAML trees etc. However, I have the problem that if I attach an Image object to a Grid, then want to use that image again, it tells me: The image e...

How to display combo box as textbox in WPF via a style template trigger?

I would like to display a combobox drop down list as a textbox when it's set to be read only. For some reason I can't seem to bind the text of the selected item in the combo box to the textbox. This is my XAML: <Style x:Key="EditableDropDown" TargetType="ComboBox"> <Style.Triggers> <Trigger Property="IsReadOnly" Val...

How to set binding in xaml to my own variable

Hello. I have an object in the code: public class UserLogin { bool _IsUserLogin = false; public bool IsUserLogin { get { return _IsUserLogin; } set { _IsUserLogin = value; } } public UserLogin() { _IsUserLogin = false; } } .... ...

how do you set a property of a control to an address of a function in xaml?

Hi, I have a control that has a "Filter" property that expects a function that defines how the contents of the control should be filtered. so far i am setting the filter in code behind as such: MyControl.Filter = AddressOf Filters.MyFilter In this example MyFilter is a shared function in the Filters class with the following signatur...

How To Raise Property Changed events on a Dependency Property?

OK, so I have this control with two properties. One of these is a DependencyProperty, the other is an "alias" to the first one. What I need to be able to do is raise the PropertyChanged event for the second one (the alias) when the first one is changed. NOTE: I am using DependencyObjects, not INotifyPropertyChanged (tried that, didn't ...

Databinding to ObservableCollection in a different UserControl - how to preserve current selections?

Scope of question expanded on 2010-03-25 I ended up figuring out my problem, but here's a new problem that came up as a result of solving the original question, because I want to be able to award the bounty to someone!!! Once I figured out my problem, I soon found out that when the ObservableCollection updates, the databound ComboBox h...

WPF: How do I set the focus on a datagrid?

I would like to set the focus on the first row of a data grid. This is what I have so far: Keyboard.Focus(ResultsGrid) If result.Count > 0 Then ResultsGrid.SelectedIndex = 0 End If This will set the focus to the datagrid, but not the row itself. ...

wpf exit thread automatically when application closes

Hi, I have a main wpf window and one of its controls is a user control that I have created. this user control is an analog clock and contains a thread that update hour, minute and second hands. Initially it wasn't a thread, it was a timer event that updated the hour, minutes and seconds but I have changed it to a thread because the appli...

wpf do animation until background worker finishes its work

Hi! I have an application that do some hard stuff when user clicks a start button and takes a long time. During this I would like to do some animation over a label, for example, changing opacity from 0 to 1 and vice versa and change foreground color between several colors at the same time changing opacity. I want it stops doing animati...

How to bind WPF TreeView to a List<Drink> programmatically?

So I am very new to WPF and trying to bind or assign a list of Drink values to a wpf treeview, but don't know how to do that, and find it really hard to find anything online that just shows stuff without using xaml. struct Drink { public string Name { get; private set; } public int Popularity { get; private set; } public Dr...

WPF: control.ItemContainerGenerator.Status is NotStarted. How do I tell it to start now?

My controls .ItemContainerGenerator.Status is NotStarted. How do I tell it to start now and wait until it is completed? ...

XamlParseException on Windows XP

I have a WPF application which runs perfectly fine on vista/7 but on Windows XP it chucks up the System.Windows.Markup.XamlParse error, and it's quite frustrating because I have a hell of a lot of controls in my application and I don't know what is causing the problem. Can anyone shine some light here? ...

How to setup a WPF datatemplate in code for a treeview?

struct Drink { public string Name { get; private set; } public int Popularity { get; private set; } public Drink ( string name, int popularity ) : this ( ) { this.Name = name; this.Popularity = popularity; } } List<Drink> coldDrinks = new List<Drink> ( ){ new Drink ( "Water", 1 ), new...

How to bind a List to a WPF treeview using Xaml?

I don't know how to bind a List of Drink to a WPF TreeView. struct Drink { public string Name { get; private set; } public int Popularity { get; private set; } public Drink ( string name, int popularity ) : this ( ) { this.Name = name; this.Popularity = popularity; } } List<Drink> coldDrinks...

How to create an array of buttons in WPF ?

I can create an array of buttons in Windows Form but how can i do that in WPF(xaml) ? thanks in advance! ...

Making "helper" windows in WPF

I'm writing an app in WPF and want to make a "helper" window. The window needs to be resizable, with no minimize option and doesn't show in the taskbar. If the app receives focus, it should appear as well, but whether or not it's in front or behind the main window should be retained. When the main window is closed, it should close along ...

WPF 4: What happened to DataGridColumnHeader?

What happened to DataGridColumnHeader? It looks like it was dropped when the DataGrid was moved into PresentationFramework. ...