wpf

Combobox in WPF loses its theme when using a style trigger. (Stumper?)

I am using style triggers to change combo box to texbox if it's readonly, but for some reason when I apply the style, it cause the combobox theme to change from Aero to Windows Classic (the theme I currently have in use on my PC). Any help would be GREATLY appreciated! Here is my code: <ComboBox ItemsSource="{Binding Source={StaticRe...

WPF How to stop animation from a thread in background worker

Hi! I have a task that takes a long time. I do it with a background worker thread and before start it, since Do_Work I begin an animation over a label and when task finishes, I stop it in RunWorkerCompleted but I received an error because I try to begin/stop animation in the background thread that is not the owner. How can I do this, I ...

Add space between items in a WPF/Silverlight ListBox without space above first or below last

Is there a standard/best way to space items in a WPF ListBox, such that there is space between consecutive items, but not above the first or below the last? To me, the most obvious way to add spacing is to modify the ItemTemplate to include space above, below, or both above and below each item. This, of course, means that there will be ...

How to synchronize two MediaPlayers or MediaElements in WPF?

I am trying to implement a system in WPF that plays two synchronized videos on two screens. I thought that if I bundled the two corresponding MediaTimelines into a single ParallelTimeline and control the timelines from the clock controller of the ParallelTimeline the clocks of the media timelines would be driven from the same clock and t...

How to implement paging for datagrid using LINQ to Entities in wpf?

I'm new in wpf. My main problem is to understand how DataGrid works with its datacontext. It would help me a lot because I don't know how to make a universal paging usercontrol for all my datagrids in the projects for different database tables. DataGrid converts received DataContext from object to some kind of list. How it is implemented...

Binding Dictionary<T> to a WPF ListBox

Given a dictionary of <string, Drink>, how would you bind the dictionary.Values to a WPF ListBox, so that the items use the .Name property? struct Drink { public string Name { get; private set; } public int Popularity { get; private set; } public Drink ( string name, int popularity ) : this ( ) { this.Na...

Button not overriding parent's IsEnabled

I have a custom control that displays a tryAgain button when the control is disabled. This nesting is causing the button to become disabled, even if I explicitly enable the button in xaml or with a trigger. Is there a way to override a parent control's "IsEnabled"? ...

Expression blend for WPF 4 release date

I understand that Visual Studio 2010 is being released 12 April, but does anyone know when Expression Blend for .NET and WPF 4 is being released? I have the beta, but it is pretty buggy and it crashes a lot. I have not had much luck searching for the release date, so any help would put my mind at ease. Cory ...

FlowDocument Repeating table header

Hi How can I know if am at the end of a page and insert a break? I'm trying to print a wpf document with repeated header. Regards ...

The best use of time at Visual Studio Launch 2010

Yes, this is a programming-related question, if a little indirectly. For better or worse, I am switching from Winforms to WPF in April. I am also going to be in attendance at the Visual Studio Launch in Las Vegas. I have a real need to get up to speed quickly in WPF, so my question is: What sessions are going to be the best use of my...

Wrap or adorn wpf listview datatemplate

I'm attempting to essentially wrap the contents of a DateTemplate in a listview gridview column with a border. What I want to know is if it's possible to supply an adorner that will surround that template so that I don't have to specify the border in every single datatemplate on every column (which is what I'm doing now). I've got some...

WPF Best point to update a progress bar from BackgroundWorker

I have a task that takes a long time executing. In order to inform about the progress to the user I have a progress bar that I update inside DoWork but I would like anybody tells me if it is the best way to update the progress bar. I have heard that there is a ReportProgress event handler but I am confused because I don't know what is th...

WPF: Draw a grid on a Canvas?

Hello community, I'm currently trying to add gridlines to a canvas. I need an exact free space between them, where I'd like to place something for hit detection per cell, maybe simply a transparent border or such a thing. While I thought this would be an easy thing, I'm facing problems like antialiasing and that lines in WPF aren't ver...

Handling events from user control containing a WPF textbox

In order to take advantage of the spell checking ability of WPF textboxes, I have added one to a user control (with the use of elementhost). This user control is used in various window forms. My current problem is trying to handle keyup events from this textbox but the windows form is unable to "get" any event from the control. I can acc...

Binding a TreeView with ContextMenu in Xaml

I'm pretty new to Xaml and need some advise. A TreeView should be bound to a hierarchical object structure. The TreeView should have a context menu, which is specific for each object type. I've tried the following: <TreeView> <TreeView.Resources> <DataTemplate x:Key="RoomTemplate"> <TreeViewItem Header="{Binding Name}"> ...

How could I make this display for listbox?

Hello everyone, I have a databound listbox which is actually displaying two columns of data. It is displayed as follows: <UserControl.Resources> <DataTemplate x:Key="AlignedPairs"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <ColumnDefinition...

WPF DataGrid programmatic multiple row selection

Is there anything simpler than sample below ? I do have observable collection ( "list" in the code ) bound to DataGrid lstLinks for (int i = 0; i < list.Count ; i++) { object rowItem = lstLinks.Items[i] ; DataGridRow visualItem = (DataGridRow)lstLinks.ItemContainerGenerator.ContainerFromItem(rowItem); if ( visualItem =...

Disable selecting in WPF DataGrid

How can I disable selecting in a WPFTooklit's DataGrid? I tried modifying the solution that works for ListView (from http://stackoverflow.com/questions/1051215/wpf-listview-turn-off-selection#comment-863179), but that doesn't work: <tk:DataGrid> <tk:DataGrid.ItemContainerStyle> <Style TargetType="{x:Type tk:DataGridRow}"> ...

How do I move the caret a certain number of positions in a WPF RichTextBox?

I want to move the caret 4 positions to the right of where my caret currently is. I'm registered for PreviewKeyDown, and calling InsertTextInRun() when the tab key is captured, like so: private void rtb_PreviewKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Tab) { rtb.CaretPosition.InsertTextInRun(" "); ...

selected checkbox in WPF

I have a lot of check boxes in my WPF form. I want to get the selected checkbox value alone. In Winforms we can use foreach(checkbox ck in controls), but I cannot use like that in WPF Forms. How can i get the selected checkbox in WPF? ...