wpf

How do I position an element within a WPF Grid column?

Let's say I want to position an element at the coordinates x=20, y=5 within the 3rd column of a Grid control. How do I do this? Do I need to add a Canvas panel to the column and then add the controls to it? Thanks. ...

In WPF/Silverlight is it possible to bind to an HTML-like TableControl?

...

WPF MVVM: Convention over Configuration for ResourceDictionary ?

Update In the wiki spirit of StackOverflow, here's an update: I spiked Joe White's IValueConverter suggestion below. It works like a charm. I've written a "quickstart" example of this that automates the mapping of ViewModels->Views using some cheap string replacement. If no View is found to represent the ViewModel, it defaults to ...

Standalone WPF Filter Control

Most WPF data grid controls around have an inbuilt ability to filter the data shown. I am interested in using that functionality, but disconnect from data grid usage. I'm hoping to find a user control that will return an Expression<Func<T, bool>> that I can use in a LINQ query. Does anyone know of such a user control? ...

Getting a reference to the ViewModel from an IValueConverter

Is there a clean and/or an accepted standard way of referring back to the ViewModel from an IValueConverter, or does that break the MVVM pattern? Basically, I want to convert bound data in the UI based on other properties of the ViewModel. I guess this is the same question as how do you refer back to the Window/Page from an IValueConve...

Setting Focus on new Items in Items Control

I've got a ListBox which is getting new items added to it through Databinding (i.e. something is getting added to the list and the box is updating to include the new item). The items in the list box are editable data templates, so the question is: How do I set the focus to the first field in the template when a new item is added? I've ...

Scrolling between DataTemplates in ListBox on a timer

I'm working on a project right now in which I need to automate animated scrolling for DataTemplates displayed in ListBoxes throughout the application. Basically something common in Javascript like this Javascript smooth scrolling example that runs on a timer. I've seen a few other people around posting similar questions like this one bu...

WPF code-behind for resources?

Hi all, I'm working on a wpf application, and up until recently, I had a ResourceDictionary inside my main window's resources part of the xaml. The resource dictionary contained an DataTemplate that was used to style several listboxes in the window. The xaml for this datatemplate contained pointers to event handlers, eg: <Button n:Na...

Change the position of a control programatically.

Hi I have a xaml code like this <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="100"/> <ColumnDefinition Width="100"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="100"/> <RowDefinition Height="100"/> </Grid.RowDefinitions> <Label Content="Test" Grid...

Resizing a control in WPF.

I have a set of user controls in my wpf form and want to give ability to user to resize them. Whenever a user clicks on a control total 8 boundary rectangles should appear and then by dragging any of them, the user must be able to resize the control. Please help me on this. ...

How to bind to a WPF dependency property when the datacontext of the page is used for other bindings?

How to bind to a WPF dependency property when the datacontext of the page is used for other bindings? (Simple question) ...

WPF: adding a usercontrol to a window

Hi guys, First off, I'm new to WPF and C# so maybe the issue I have is really easy to fix. But I'm kinda stuck at the moment. Let me explain my problem. I have a WPF Window and two usercontrols (Controls and ContentDisplayer). The usercontrol Controls, wich contains some buttons, is added in the XAML of the Window. Nothing special he...

[WPF] Reapplying template for ListBox item programatically

Basically, I have a list of colors and a defined datatemplate for listbox item: <DataTemplate x:Key="colorItemDataTemplate"> <Border x:Name="borderInner" BorderBrush="Black" BorderThickness="1" Background="{Binding Brush}" Width="11" Height="11" /> </DataTemplate> Now, when I add a bunch of items into the listbox and then set the ...

WPF drag & drop between containers

I've got a container, say a Grid. It has two containers, say StackPanels. StackPanel #1 has some rectangles. What's the best way to enable a user to drag a rectangle and drop it in the StackPanel #2 (and have that rectangle be a child of StackPanel #2). I've got the drag bit sussed - the only thing that's unclear is whether to actual...

WPF - Get Hyperlink command from data?

In WPF, how can I get a reference to the Command that a Hyperlink should invoke from an object property? I am creating a WPF application, using the MVVM pattern. A list box in the main window dislays hyperlinks. Each hyperlink will invoke one of the view model's ICommand properties when it is clicked. How do I specify which ICommand sho...

How do I bind to the SelectedItem property in a ControlTemplate?

Consider the following Control/Template <my:ExpandingListBox Margin="0,2,0,0" x:Name="TagSearchListBox"> <my:ExpandingListBox.Template> <ControlTemplate TargetType="{x:Type my:ExpandingListBox}"> <Border Name="MyBorder" BorderThickness="2" BorderBrush="Black"> <Grid> <TextBlock...

Show tooltip outside of current Window

Hello, I have .NET WPF application and one of requirement is that user may select and copy text outside of my application. My application has to respond to clipboard event. Look up word from dictionary and next to selected text show tooltip with word's translation. As I understand this has to be accomplished using calls to Windows API...

Silverlight/WPF Many to Many List of Checkboxes Binding

I have an entities model with a many to many relationship. For simiplicity, lets assume its a car entity and a feature(cd player, moonroof, etc.) entity. I have a Silverlight/WPF form in which you edit the car entity. I would like to have the list of possible features (everything in the features table) be a list of checkboxes. That par...

WPFMVVM Set Control Focused

How in MVVM do you set a User Control Focus? Using Focusmanager.FocusElement={Binding ...} Has no affect. Here is my XAML: <DataTemplate DataType="{x:Type client:TelephoneNumberViewModel}"> <Grid FocusManager.FocusedElement="{Binding ElementName=TelephoneNumber}" Width="1024" Height="540"> <Grid.RowDefinitions> ...

Is there Selected Tab Changed Event in the standard WPF Tab Control

Hi, Is there an event that an be used to determine when a tabcontrol's selected tab changes in WPF? I have tried using TabControl.SelectionChanged - but it is getting fired many times when a child's selection within a tab is changed. Thanks! Jon ...