wpf

How to remove input binding added through CommandManager.RegisterClassInputBinding?

I used CommandManager.RegisterClassInputBinding to add binding to the whole type. Now I wan't to remove it. This is what I tested. private void CommandBinding_Executed_1(object sender, ExecutedRoutedEventArgs e) { CommandManager.RegisterClassInputBinding( typeof(TextBox), new InputBinding(TestCommand, new KeyGestur...

I have some questions about MVVM pattern

Hello, My name is Jesús from Spain, I'm a .NET developer and I just discovered this great web few days ago. I have some questions about MVVM pattern and I will be glad if you can answer they. I started WPF 3 months ago and I learned the MVP pattern. MVP is so good because you can structure the app so well. I started seeing the mvvm pa...

WPF Textbox & Borders - curious resizing behavior

The following XAML produces a window with strange behavior around the textbox: <Window x:Class="WpfSandbox.CuriousExample" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="CuriousExample" Height="300" Width="300"> <DockPanel Margin="15"> ...

Designing WPF UserControl that gets its DataContext from outer controls: What is best practice to have some sample data in designer but use inherited DC at runtime?

Hi, I am designing a WPF user control which contains other user controls (imagine a WidgetContainer, containing different Widgets) - using M-V-VM architecture. During development, I have WidgetContainerView in a window, window (View) spawns a WidgetContainerViewModel as its resource, and in a parameterless constructor of WidgetContainer...

Using the parent's DataContext (WPF)

Hello, I looked over this web and google and the solutions didn't work for me. I have a command on the ViewModel of a UserControl. Well, The usercontrol have a ItemsControl binded to a ObservableCollection. Inside the DataTemplate of the ItemsControl.ItemTemplate I have a button and I want to use the command. I can't bind the command be...

How do I display a loading icon while a Frame navigates?

I have a WPF application with a Frame and a TreeView. The TreeView displays the menu for my application, and when an item is clicked, the Frame displays the content for that menu item via a call to Navigate. That call sometimes takes several seconds, and UI is blocked while navigation completes. I have a control with animated spinning...

Designing data templates for WPF

Using WPF, XAML, VS2008, and Blend 2 (or 3 Beta preferred), what is your process for creating data templates? Do you have a process for testing the data template's appearance WITHOUT spinning up your app just to test how the data looks? Is there a process I can use in Blend to make developing data templates more graphical? ...

Alternative to INotifyCollectionChanged

I'm starting to dip my toe into WPF, and I would like to have the collections in my application work with as an ItemSource. I tried implementing INotifyCollectionChanged. I'm ok with that except that then I have to reference WindowsBase.dll in about 15 dll's. Is there another interface that WPF can use for binding that I might already...

WPF: How to refresh a window while debugging?

I am debugging an algorithm that is being represented by a set of ViewModels. In order to debug this algorithm I would like to redraw the View while stepping through part of the algorithm. Is this possible? (I would prefer to just repaint, not do what they call "DoEvents" to process all events.) ...

Determing what caused a WPF binding's ValueChanged event to fire

It appears that the ValueChanged and SourceUpdated events will fire simply by setting the DataContext. Does anyone know of a way to tell whether the value changed is actually from some user interaction? A simple example is to have a "Save" button on a WPF form that is disabled until the user actually changes the data. Since both Value...

Adding a second thumb to the slider control in WPF

Hello Everyone, I am trying to make a range control which is basically a slider control with an extra thumb. The only code I found for one already built is here. http://www.codeplex.com/AvalonControlsLib For the life of me I cannot get a tooltip to show up above each thumb (with the current value) while it is being moved. It will sh...

forcing Validation; WPF, DataGrid, ObservableCollection

I have a WPF DataGrid. I read a csv file and build an ObservableCollection of objects. I set the DataGrid.ItemsSource to the Collection. I would like to then force a RowValidation on every row in the DataGrid. If I, playing user, edit a cell, the RowValidation fires, all is well. But the Validation does not fire on the initial load. ...

How can I update ListView when my data source changes?

http://windowsclient.net/learn/video.aspx?v=108085 In that video, when I changes data source by add more data the list view doesn't update? Please help me! ...

Setting a style's TargetType property to a generic class

Is it possible to set a style's TargetType property in XAML to a Generic Class? public class Selector<T> : Control { } and then in xaml <Style x:TargetType="Selector"> <Setter Property="MyProperty" Value="Green" /> </Style> This wont work because Selector is missing a type argument. ...

SelectedItem in a WPF Treeview

How can I retrieve the item that is selected in a WPF-treeview? I want to do this in XAML, because I want to bind it. You might think that it is SelectedItem but apparently that does not exist is readonly and therefore unusable. This is what I want to do: <TreeView ItemsSource="{Binding Path=Model.Clusters}" ItemTemplate="{Stat...

How do I access the children of an ItemsControl?

If i have a component derived from ItemsControl, can I access a collection of it's children so that I can loop through them to perform certain actions? I can't seem to find any easy way at the moment. Cheers J ...

How do I focus a modal WPF Window when the main application window is clicked

I have my MainApplication Window that launches a new Window with .ShowDialog() so that it is modal. UploadWindow uploadWindow = new UploadWindow(); uploadWindow.ShowDialog(); Now users are often leaving this window open and it can get lost under other windows. When the MainApplication is clicked you get an error-like beep and are unab...

ResourceDictionary in WPF Control Library

Hello - We are creating an office ribbon that opens up a WPF window that is stored in another WPF Control library project. That WPF window has some themes attached to it that is stored in a ResourceDictionary that is compiled in a separate project. However when we load up the WPF window, all the themes from the ResourceDictionary are ...

How to make a WPF control that updates every second?

This question is similar to another one I asked, but whereas in that case I wanted to know about forcing a binding to update from XAML or a view model, in this case I'd like to know about wrapping this up into a custom WPF FrameworkElement. The functionality I'm after is a span of text that indicates how long ago something happened. <T...

WPF ListView question

Hello guys, this is my first question here. I'm getting started with WPF and i am stuck. Here is the problem: I have a ListView as following: <UserControl.Resources> <DataTemplate x:Key="FirstCell"> <StackPanel Orientation="Horizontal"> <CheckBox Margin="2"></CheckBox> </StackPanel> </DataTemplate>...