wpf

Default Text in the Drop Down.

I am working on a wpf application, when using Combo Box control i am assigning ItemsSource to it. So, it displays a list of items with no item selected, now user can select an item of his choice. When user has made a selection he has no option to undo that. I want him to be able to get the initial state where no item is selected. How can...

How do I animate UserControl objects using Storyboard and DoubleAnimation?

In my WPF application, I have a Canvas object that contains some UserControl objects. I wish to animate the UserControl objects within the Canvas using DoubleAnimation so that they go from the right of the Canvas to the left of the Canvas. This is how I have done it so far (by passing the UserControl objects into the function): pri...

How do I set MenuItem's Icon using ItemContainerStyle

I'm following the example here of binding a MenuItem to a data object. <Menu Grid.Row="0" KeyboardNavigation.TabNavigation="Cycle" ItemsSource="{Binding Path=MenuCommands}"> <Menu.ItemContainerStyle> <Style> <Setter Property="MenuItem.Header" Value="{Binding Path=DisplayName}"/> ...

Enable command binding for TextBlock

I am developing a WPF application, and have a TextBlock which I want to use command binding to trigger a command on when clicked. What's the best way to achieve this? The TextBlock-control does not have a Command property, but it does have a CommandManager. What is this? Can it be used for command bindings? I've seen many other contro...

wpf data binding for novice

Hi! While learning c# and wpf, i am trying to get grasp of data binding. So far unsuccessful. All the help i could find on the net, even if described as "for beginners", is too complicated for me to begin to understand. I would appreciate if someone can provide a code for binding in a very simple example: namespace BindingTest { cl...

WPF Toolkit Datagrid and ListViewCollection SortDescriptors

Hi all I have a weird problem with datagrid. I have a list with 2 items, inside every item there is a ListCollectionView. A datagrid is binded to the selected item's ListCollectionView. if I add (in code) a sort description to the selected item's ListCollectionView ,select item 2 and then select item 1 again the ListCollectionView so...

WPF datagrid sort direction

How can I see the sort button & direction per column in my datagrid? Or even better, how can I see a seperator between the column headers? here's my grid code: <Window.Resources> <Style x:Key="HeaderTextStyle" TargetType="{x:Type dg:DataGridColumnHeader}"> <Setter Property="Background" Value="DarkSlateGray" /> <Set...

How to ensure that no item is selected in databound ListBox?

OK, this must be a duplicate question, but I cannot find the answer: I have a listbox that is databound to a Collection. By default Items[0] is selected. How can I prevent this in order to ensure that the SelectionChanged event is raised any time I click a ListBoxItem? EDIT: I had already dismissed the SelectedIndex=-1 route, but I trie...

Dropdown Menu in WPF Toolbar

Having some layout frustrations in WPF- I'm using a ToolBar to house a set of controls, most of which are Buttons and one of which is (going to be) some sort of dropdown menu. In WinForms, the ToolStripDropDownButton was perfect; however, I can't seem to figure out the best way to replicate this behavior in WPF. Any ideas? ...

WPF ListBox - how to put values from dataTable?

Hello, I have ListBox and want to put values in this listbox from DataTable: listBoxVisibleFields.DataContext = SelectedFields; Where SelectedFields is a DataTable filled with data. But this code does not work. My listbox is empty. As i remember, in WinForms was sucha a thing for list box like ValueMember and DisplayMember, but in WPF...

real time loop counter ouput wpf

What can I do if I want to have a text-box representing in real time the value of a loop counter in wpf? appending working solution: public partial class Window1 : Window { public Window1() { InitializeComponent(); } private delegate void UpdateTextBox(DependencyProperty dp, Object value); ... private void MyMe...

XAML Editor hangs for 4-10 seconds driving me mad

I know similar questions exists but they don't address this exact problem. I'm having an issue with Visual Studio 2008 SP1 whereby it hangs for 4-10 seconds whenever the xaml edit receives focus. It is literally driving me to despair and I'm about to move back to Winforms. Note - Just editing the straight up xaml (i.e no designer enable...

How to get the wpf listboxitem to stretch entire height of listbox when selected...

Hi, How can i get the listbox item to stretch the entire height of the listbox when it is selected.My situation is like my listboxitem contains an expander which expands and shows another list.The second listbox is quite long and i am looking for some way to prevent the user from scrolling a lot.I am looking for some way to give the seco...

WPF templating/styling issue

Given this piece of XAML <DockPanel> <DockPanel.Resources> <Style TargetType="{x:Type GroupBox}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type GroupBox}"> <DockPanel> <Border DockPanel.Dock="Top"> <Border.Resources> ...

Expression Blend Release mode

I work almost exclusively in Release mode since debugging it is good enough for the rare times I need to debug. I've recently started trying to use Expression Blend 3 for my xaml, but it seems to only work with the debug version of my project. Is there any way to change this? I'd really like to avoid having to build everything debug...

WPF - add static items to a combo box

I've said it before and I'll say it again, the easiest examples for WPF are also the hardest to find on the web :) I have a combo box that I need to display but it doesn't need to be databound or anything else, the content is static. How can I add a static list of items to my combo box using XAML? ...

WPF Binding Custom Output Window

I am trying to create a custom Output Window for my software that is bound to my ViewModel. Usually in the past I have always used a TextBox and used the appendText() method to write to the Output Window. Of course with a ViewModel and trying to bind to a Textbox, it seems you can only Bind to the Text property. Below is what I am trying...

Moving from WPF 3.5 to 4.0 causes error "Can't put a page in a Style"

Hi, I'm in the process of moving my application from .NET 3.5 to .NET 4.0, and I get the following error message : "Can't put a page in a Style". I've implemented the MVVM pattern for this application and use Data Templates to tell the application how to render my various view models...for example below. <DataTemplate DataType="{x:Typ...

Multithreaded access to the WPF GUI in C#

Hello, I'm trying to create a custom, in-house application that is going to access other internal systems which broadcast their names and IP addresses via UDP. I'm trying to create a multi-threaded dialog that polls for UDP messages every 500 ms for 15 seconds, parses the UDP messages and then adds the names of the detected systems to ...

XAML Indexer DataBinding

I have got an Indexer property in a Class called X, suppose X[Y] gives me a another object of Type Z <ContentControl Content="{Binding X[Y]}" ...??? How can I make a DataBinding happens inside indexer? It works if I do {Binding [0]} . But {Binding X[Y]} just takes the indexer parameter as a string which is "Y" Update : Converter i...