wpf

C# Can I disable keyboard input to a specific control?

Is it possible to disable keyboard input to a control ? For instance a listview ? Ho do I do that? I've tried overriding the KeyUp KeyDown events but apparently that was not the way ? IsEnabled is a good solution, however I only wish to disable keyboard interaction and leave mouse interaction intact. ...

Using WPF components in NUnit tests - how to use STA?

I need to use some WPF components in an NUnit unit test. I run the test through ReSharper, and it fails with the following error when using the WPF object: System.InvalidOperationException: The calling thread must be STA, because many UI components require this. I've read about this problem, and it sounds like the thread ne...

Modifying UI from commands - using command binding in WPF

In my WPF application I have a TextBox and a Button. The button has a command binding to a command that will do something with the text. <TextBox x:Name="_textBox"></TextBox> <Button Command="{Binding SomeCommand}" CommandParameter="{Binding ElementName=_text, Path=Text}" Content="Trigger SomeCommand" /> Now, I want ...

Replace part of default template in WPF

Hello, is there any "best practice" way to replace a part of the default template. The current use case is a treeview. As default, the treeview has this small triangle shapes to expand and collapse. I know how to replace these if I replace the whole control template, as shown in the code below. I am not sure if there is a way to "keep ...

WPF Contextmenu with gridcontrol

One Contextmenu in my application has Grid controls ( with buttons ) as menuitems. <RichTextBox.ContextMenu> <ContextMenu Width="280"> <Grid Width="240" Height="65"> [...] </Grid> </Contextmenu> </RichTextBox.ContextMenu> The Problem is when I first open the ContextMenu and move the mouse over it, ...

How to databind MenuItem collection directly into XAML

I have a UserControl which contains a ListBox. And ListBox uses another UserControl as DataTemplate. <ListBox x:Uid="SectionList" x:Name="SectionList" ItemsSource="{Binding}"> <ListBox.ItemTemplate> <DataTemplate> <Grid> <expander:ExpanderDataTemplate/> </Grid> ...

WPF Listview binding to ItemSource?

Hi, I have the following listview, but it doesn't show the actual records, but only the namespace of the object. I wondered if I need to create the columns in XAML for it to show the records and then bind it to some properties of an object or what is wrong with this? <ListView Name="ListCustomers" ItemsSource="...

Wpf Combobox Binding in ListView

Hi i´ve got a problem with the databinding of a combobox in a listview. i have two classes: - Transaction - Substrate the Transaction has a attribute of the Substrate and the Transactiona are saved in a Datebase. At the start of the programm i want to load all Transactions as a list and show them in a ListView. Each possibility of Subst...

3d object visible in WPF

I'm playing around 3d objects in WPF. I have a viewport3d. This contains two 3d object (ModelVisual3d) named "A" and "B". I want to just show A and hide B, sometimes, I want to just show B and hide A. How can I do hide it? I'm found answer, but this tell "set the OffsetX property to 1000.". I don't like it. Is it possible to hide ...

MVVM multiple views

Im trying to learn MVVM so far its going well , I have stumble on a situation which I don't know how to implement .. What I want : - A view with left navigation and right details pane .. right details will have a contentcontainer which would hold my User Controls for the views to be selected by left pane What I have : - A MainVie...

Getting x,y coordinates of a texture mapped on sphere (WPF, synch, no visualtreehelper.hittest)

Hello everyone, technology: WPF, C# pretext: I am making a game with a custom gyroscope+accelerometer device. I have a sphere that has a labyrinth map on it. The texture is mapped by a set of positions and texture coordinates generated from 3rd party. The user rotates the sphere via device trying to solve the labyrinth. question: I ...

WPF command support in ComboBox

I want to have a command on my viewmodel execute on the selectionchanged of my ComboBox. Obviously Combobox does not support executing commands. I have created a new class that inherits from Combox and implements this interface. When I try to view the control (in the designer or in debug) the control doesn't show. I don't get any excep...

Button style not getting updated when manually updating data source

I have a dialog with two textboxes and a button. The button's IsEnabled style is set dynamically based on whether the data validation of the two textboxes succeeded. <Button Content="Finish" x:Name="btnFinish" Click="btnFinish_Click"> <Button.Style> <Style TargetType="{x:Type Button}"> <Setter Pro...

WPF ListView.Items.SortDescriptions Error

Hi, I am using the WPF SortDescriptions sorting technique and I have found that it will not sort numbers. When given a column of numbers to sort it tells me that "Failed to Compare two elements in the array" Does anyone know how to get around this? Or maybe give me some hints? I noticed that it will only sort strings right, but not nu...

WPF: ItemsControl and DataContext

I have a main window with a single user control in it, called SuperMode. SuperMode consists of a collection of people and each person in this collection has their own collection of tasks. Sounds simple, right? From file SuperMode.xaml: <UserControl x:Class="Prototype.SuperMode" xmlns="http://schemas.microsoft.com/winfx/2006/xa...

WPF usercontrol

Hi, I've got a parent UserControl which has a property which I would like to access from a child usercontrol of the parent. Is this possible? I'll be doing this through the child control's viewmodel. Just wanted to get an idea on the best approach to do this. Thankyou. ...

WPF ComboBox a better way to format ItemsSource

Morning Guys, I have a few ComboBoxes bound to List of TimeSpan. I am formatting the TimeSpans using IValueConverter and ItemTemplate. I was wondering if there were an easier way to format the TimeSpans. Here's what I'm currently doing. public class TimeSpanConverter : IValueConverter { #region IValueConverter Members public o...

Is there any way to inherit from TriggerAction class?

I am not interested in animations and I am trying to make simple setter action to be set without key frames. I wanted to inherit TriggerAction; make properties that set the new value on target, any additional optional properties so I can use: <EventTrigger SourceName="btn" RoutedEvent="Click"> <BooleanActionTrigger TargetName="cb" ...

WPF: ListBox - setting focus on an item breaks keyboard navigation

After selecting ListBox item programmatically it is needed to press down\up key two times to move the selection. Any suggestions? View: <ListBox Name="lbActions" Canvas.Left="10" Canvas.Top="10" Width="260" Height="180"> <ListBoxItem Name="Open" IsSelected="true" Content="Open"></ListBoxItem> <ListBoxItem...

NTLDR error message and the WPF

Hello, I am building an application using the WPF. This application is for presentation purposes, the user can draw shapes, write text play audio and video ...etc. but I have an error message about the NTLDR when I am running the application on the Windows XP and actually I do not have any clue of where I can find the problem. I would ...