wpf

WPF TabControl On SelectionChanged, set focus to a text field

I have a tab control, and a few tab items. I am successfully listening to the SelectionChanged event, and checking if the tab I'm interested in is the currently selected one. I'm using this code (below), and stepping through the debugger, I can see that my branching logic works as designed; however, the issue I'm having is that somethin...

WPF: bind to a List inside a class

I have a File class defined as following public class File { public string FileName {set;get;} public List<Property> PropertyList; } Here is how Property class looks like: public class Property { public string PropertyName { set; get;}; public string PropertyValue { set; get;}; ... } I need to bind a List<File> to a DataGrid, ...

WPF Treeview - Binding to a collection with different depths, and styling differently

Apologies for the long post -- Read a few threads about this, but still find it hard to implement. Basically, I have a collection of objects, defined as: public class LibData { public string Name { get; set; } ObservableCollection<LibObject> _list; public ObservableCollection<LibObject> List { get { return _list; } } pu...

How to use entitycollection for binding to wpf UI

I'm using EntityFramework for data access and wpf as UI. If I bind WPF components to navigation properties of my entity classes(usually EntityCollection<EntityClass>, exposed as IList<T> in service layer), UI is not updating the changes. I know i have to use ObservableCollection<T> or such, but I need some guidance on how to use it witho...

CollectionView with Filter not updating after ObservableCollection<T>.Move

Using .NET 3.5, I'm finding that a CollectionView with a filter doesn't update when the underlying ObservableCollection(T) has items moved using ObservableCollection(T).Move. As a sanity check, I started with a simple project, one of Bea Stollnitz' from this page: http://bea.stollnitz.com/blog/?p=31. The actual project can be download...

Element host first time creation performance.

Hi , We have WPF app and sometimes we display windows panel with windows controls. And one of those controls can be again a WPF control, which is hosted in element host. WPF (MainWindow) WindowsFormsHost Windows(Panel) Elementhost WPF(usercontrol) This windows Panel on an average has 2-3 wpf controls. Ever...

WPF4 TabControl/Grid in a DockPanel is hiding StatusBar

I have a window filled with a DockPanel containing 3 elements, a MenuBar docked at the top, a StatusBar docked at the bottom and a TabControl filling the body. At least, I would like the TabControl to fill the body. In the visual designer, the TabControl and StatusBar are laid out side by side instead of top & bottom. When I run the...

How to set DataContext for a single element?

The beginner tutorial I've followed said I should create a namespace on the window, <Window ... xmlns:vm="clr-namespace:MyApp.ViewModels" /> And then set the DataContext like this, <Window.DataContext> <vm:MyViewModel /> </Window.DataContext> But I don't want the DataContext to apply to the whole window. I want different elemen...

StackOverflowException on InitializeComponent

I'm trying to follow this little tutorial, but I keep getting this exception. The relevant XAML looks like this: <StatusBar Margin="0,288,0,0" Name="statusBar" Height="23" VerticalAlignment="Bottom"> <StatusBar.DataContext> <m:MainWindow /> </StatusBar.DataContext> <TextBlock Name="statusText" Te...

InvalidOperationException when creating LinearGradientBrush in multi-threaded WPF app

In a static C# method, I do var brush = new LinearGradientBrush(_snazzyGradient);, and this line throws an exception. _snazzyGradient is defined as follows: private static readonly GradientStopCollection _snazzyGradient = new GradientStopCollection { new GradientStop((Color)ColorConverter.ConvertFromString("#DBF3FF"), 0...

WPF Setting the colour of the ComboBox down arrow button

I am trying to style a WPF ComboBox so that it matches a black-theme that is being considered for our next project. My problem is that if the ComboBox's background is black, the button doesn't show up (since it is also black). For some reason I have not been able to find any information about how to change it's colour. The following X...

WPF - How to have certain ListView items span columns?

I have a set of data that I'd like to present via a WPF ListView in this way: Column1 Column2 Column3 --GroupName1-- Item1 part2 part3 Item2 part2 part3 --GroupName2-- Item3 part2 part3 Item4 long_text_in_both_columns Item5 part2 part3 --GroupName1-- Item6 part2 part3 Item7 long_text_...

BlockingCollection + UI Thread

I've followed this tutorial, to create a priority queue and wrapped it with a blocking collection. I've got a DataGrid which I've wired to the underlying priority queue which emits change events. I can add items to the collection from the UI thread w/out a hitch, and it blocks when the buffer is full as it's supposed to. Now how do I co...

WPF - TabControl binding to TabItem property in an ObserverableCollection

I have an ObservableCollection<Item> and I want to set it as the ItemsSource property of a TabControl. The Item class contains a Property TabItem that returns a System.Windows.Controls.TabItem. I want the TabControl to display the TabItems from the collection. (In reality, there are lots of properties on the "Item" class.) Code: Ite...

Is there a collaboration tool example in silverlight or WPF for multi user? (like google docs but not that complex)

We are designing a C# product which involves multiple users accessing common piece of data. In short something like google docs but not that complex. Is There any good example for architecture or design to follow, read, understand. And adding to the complexity, user can belong to different geographical location. ( is distributed datab...

How to disable accelerator key for some buttons

I am setting the .Content value of a Button to a string that contains underscores; the first underscore is being interpreted as an accelerator key. Without changing the underlying string (by replacing all _ with __), is there a way to disable the accelerator for non-menu Buttons? ...

Where to put Application level resources in a mixed WinForms + WPF application.

At present we host a number of WPF controls in a WinForms application. I would like to create a number of global resources at the application level, where is the best place to do this? If this were a straight WPF application I'd put them in them App.xaml but we never create a System.Windows.Application, the controls just go into the Win...

[WPF] ItemsControl : how to do hittest to find item / index under mouse position ?

In my Canvas I have children with a specific design which includes an ItemsControl. In the OnPreviewLeftMouseButtonDown handler of my canvas, I perform a hittest using VisualTreeHelper, and when I find a specific ItemsControl I'd like to know which item / item-index the mouse was over. Does anybody know how to do this ? ...

How set property background "Transparent" in listbox

I have ListBox and i need set background "Transparent". I've selected in red, then that should be transparent: style ListBox, ListBoxItem, ScrollViewer and ScrollBar: <Style TargetType="{x:Type ScrollBar}"> <Setter Property="Stylus.IsFlicksEnabled" Value="false"/> <Setter Property="Foreground" Value="{DynamicResource {x:Sta...

WPF error template not showing

Hello, I get no binding errors and this code works at another place. I haven`t found out yet what I do now differently to the code where it works and its not that much code. In UserControl.Resource: <Style TargetType="TextBox"> <Setter Property="BorderBrush" Value="DarkBlue"/> <Setter Property="BorderThickness" Value="1" /> ...