wpf

WPF Context menu doesn't bind to right databound item

Hi! I have a problem when binding a command in a context menu on a usercontrol that is on a tab page. The first time I use the menu (right-click on the tab) it works great, but if I switch tab the command will use the databound instance that was used the first time. If I put a button that is bound to the command in the usercontrol it wo...

Why doesn't button click event "bubble up visual tree" to StackPanel as MSDN article states?

In the MSDN article Understanding Routed Events and Commands In WPF, it states an event will bubble (propagate) up the visual tree from the source element until either it has been handled or it reaches the root element. However, in this example, when you click the button, it doesn't "bubble up the visual tree" to get handled by the...

Control does not refresh after CanExecute-Result does change

Hello in my window I have buttons for load and save methods. I use CommandBinding and the save-button has a CanExecute property to keep the user from saving the data before it is loaded. The CanExecute-Methode is connected to a simple bool value called "canSaveXML" private void Save_CanExecute(object sender, CanExecuteRoutedEventArgs...

Updating Binding immediately when DataContext changes

I am trying to measure an object immediately after changing the DataContext, but the binding for the object is not getting updated soon enough. Here's my code: // In MeasureOverride(Size) m_inputWidth = 0.0; Size elemSize = new Size(double.PositiveInfinity, RowHeight); MapElementView ruler = new MapElementView(); // Measure inputs for...

LastChildFill Not Working When Trying To Dock ItemsControl

I've got the following markup in a WPF UserControl: <Border Name="_border" BorderThickness="4" BorderBrush="Blue"> <Canvas Name="_canvas" Background="Black" > <DockPanel LastChildFill="True"> <ItemsControl Name="_itemsControl" Background="Bisque" AllowDrop="True" Height="100" Width="100" Ho...

How can I call a bound method in XAML with the parameter of a TabItem's name?

I've got an instance of an object bound in XAML. It's got a method that will return to me a list of other objects (based on the property value I pass this method, it will return all the objects with that property value). <ObjectDataProvider ObjectInstance="_this.DataContext" MethodName="GetListByCategory" x:Key="List"> <ObjectDa...

WPF - How to dock a Border onto a Canvas?

I have a Border inside a Canvas. The Border's height/width are varying according to its contents. I want the Border to stretch out to fill up the entire Canvas. How can I do that? I have tried this on the Border without success: Height="{Binding ElementName=MainCanvas, Path=Height}" Width="{Binding ElementName=MainCanvas, Path=Width}"...

WPF MVVM ComboBox SelectedItem or SelectedValue not working

Update After a bit of investigating. What seems to be the issue is that the SelectedValue/SelectedItem is occurring before the Item source is finished loading. If I sit in a break point and weight a few seconds it works as expected. Don't know how I'm going to get around this one. End Update I have an application using in WPF using...

WPF can only open one window?

Assuming two projects, a WinForms project and a WPF project, in the WinForms project there is no problem with the following code being in Main() and removing the Application.Run: while (true) { Thread.Sleep(1000); Form1 window = new Form1(); window.Show(); Thread.Sleep(1000...

Avoid TextBox vertical stretching

How can I avoid TextBox vertical streching in following example: <StackPanel Orientation="Horizontal"> <Button Height="40">OK</Button> <TextBox Width="200"></TextBox> </StackPanel> ...

In WPF/XAML how do I change the size of a paragraph of text using a scroll bar?

I'm new to WPF/XAML & I'm just doing a training exercise at the moment. I've got a noddy application and I want to change the size of the text in a tag based on the position of a scroll bar. The text is defined by this code: <FlowDocumentScrollViewer Grid.Row="1"> <FlowDocument> <Paragraph> Text goes here ...

Highlight whole TreeViewItem line in WPF

If I set TreeViewItem Background it highlights the header only. How can I highlight the whole line? I have found a post almost solving a problem http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/b04f73e2-0b10-4d97-a6da-64df2e30c21d/ But there are some problems: 1. It does not highlight the whole line 2. The tree has XP style on...

Add programmatically ListViewItem to Listview in WPF

How it can be done in C#? ...

Selecting items in a listbox using C#

Hi, I am using two listbox controls in my wpf window that are identical (identical = itemsource of both the listbox is same and so they look same) and the selection mode on both the listboxes is set to Multiple. Lets call the listboxes LB1 and LB2 for the time being, now when I click an item in LB1, I want the same item in LB2 to get se...

Bind to specified XML-element

In short: I want to define what XML ButtonSettings element to use for a XAML-Button, and to use the childs of the selected ButtonSettings-element in a style applied to that Button. Is this possible? A sample of the XML: <Buttons> <ButtonSettings ID="Bye"> <Text lang="NL">Doei!</Text> <Text lang="DE">Tsusch!</Text> <Tex...

WPF - Animate ListBox.ScrollViewer.HorizontalOffset?

I have a collection of Visuals in a ListBox. I need to find the XPosition of an element inside it and then animate the HorizontalOffset of the ListBox's ScrollViewer. Essentially I want to created an animated ScrollIntoView method. This gives me a couple of problems. Firstly, how can I get a reference to the ListBoxs scrollviewer? Se...

How to fetch string from resource to assign in WPF Resource section in xaml

I have a XBAP application with the following user control: <UserControl x:Class="XXX.UsersGrid" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="Auto" Width="Auto"> <UserControl.Resources> <DataTemplate x:Key="U...

WPF vs Silverlight 3.0

Silverlight 3.0 beta has just been announced at Microsofts Mix Conference in Las Vegas. Two features of the new beta are 3D-graphics and the ability to run applications outside of the browser, which to me seemed to be two of the major features that WPF (Windows Presentation Foundation) previously offered over silverlight. I am currentl...

What is the difference between a stackpanel and a virtualizingstackpanel in WPF?

What is the difference between a stackpanel and a virtualizingstackpanel in WPF? ...

WPF: Aggregating properties on a ListBox

I have two ListBoxes, both use Extended SelectionMode. The ItemsSource of the first is a List, and uses a datatemplate. I'm trying to use an aggregation of some property from the first as the itemssource for the second. For example: public class MultiAppPropertyAggregator : IValueConverter { public object Convert(object value, T...