wpf

Animate a StackPanel when the property Visibility changes

In WPF 3.5 (with SP1), I have simply StackPanel that I would like to animate when I change the property Visibility. I have no idea of the height of this StackPanel since its content determines its height. So when I change the property of my StackPanel to Visible (progressPanel.Visibility = Visibility.Visible;) I would like to see an anim...

Is WPF production ready?

Hi, I'm wondering if there are people out there with experience of WPF application development - and maybe more interesting - running WPF in production. Is it mature enough to use in larger projects? What are the obvious pitfalls? Any best practices? (Databinding in WPF seems pretty nifty but does it work in 'real' projects?) Thanks ...

Duplex Callbacks or Client-Side Threading for Responsive WCF Clients

I have a certain service where specific functions will take longer to call than others, sometimes they might take seconds to return. In order to prevent the client's UI being blocked when this happens what is the preferred solution: Use a Duplex channel and simply use the callbacks to update the UI when data is received. Use a separate...

WPF Shape Rectangle Binding

Hi Guys. I'm trying to make some kind of shape in wpf, which does resize itself to the content (which should be text). Unfortunately, the stretch property isn't the right thing, since I want only the width of the Shape resized and without the borders (pls copy bottom example in xamlpad to see for yourself) of this shape stretched. The bo...

ListBox ItemsSource dynamic filter WPF

Hi I want to make a UI virtualization via the datasource. The idea is to "Filter" what i send to the UI (a listbox in my case). I noticed that the ItemsSource (an observable collection) is read once and that changing the Filter does not trigger refreshing... I don't understand why Thanks Jonathan ...

Building a WPF UI on a workerthread?

I have to buil a rather complex WPF UI (a hughe Grid) in code (no xaml invloved). Is there a way to stop the main UI thread from blocking while beeing in the process of building the Grid? Are there some portions of building the UI that can be outsourced to a workerthread? What parts of UI creation actually have to be on the UI thread? ...

PreviewCanExecuteEvent not executed

Hi folks I have a problem with my WPF program. I'm trying to create an object that will add handlers to all controls in the same scope. The following line does not work. The event is not handled. element.AddHandler(CommandManager.PreviewCanExecuteEvent, new CanExecuteRoutedEventHandler(scope.CanExecutedHandler), true); I also have ...

HierarchicalDataTemplate and TreeView binding compilation error

Hi, I have implemented a UserControl and put a TreeView control on that. The XAML file looks as follows. I am using a HierarchicalDataTemplate for data binding with the Treeview, <UserControl x:Class="Trinity.Windows.Viewer.Alarm.AlarmPage.TrinityDeviceTree" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xml...

HierarchichalDataTemplate and Treeview compilation error

Hi, I have implemented user control and put TreeView control on that, XAML file looks as follows I am using HierarchicalDataTemplate for databinding with Treeview, <HierarchicalDataTemplate DataType = "{x:Type src:Partition}" ItemsSource ...

Remove all left padding from WPF ListBox

Each item in a WPF ListBox control seems to have a bit of left padding. How can I restyle to remove all padding? ...

Obtaining Listbox Item Index through Attached Property

Using this posting as reference, I am attempting to display a Listbox item's index by implementing an attached property. I'll be the first to admit that I don't entirely understand how an attached property will solve this problem but I was hoping it would become clear after successfully implementing the solution. After spending countless...

WPF binding to XPath-reachable value of an element property

I'd like to bind to a value reachable only with XPath from the property of an element. The element is a ComboBox populated from some XML, and its property is SelectedItem. SelectedItem points to an XML element, and I'd like to bind to a child element's value within that, which can be reached with an XPath. The XAML looks like this, so ...

WPF LinkLabel implementation strategy

I am attempting to create a LinkLabel control for WPF. Essentially, I'm going to create the LinkLabel from a TextBlock and handle MouseEnter, MouseLeave, and MouseLeftButtonUp events. In the back end I have a base class that has properties that you would expect to see with a LinkLabel. With most other clickable controls in WPF, there is ...

How do I use CaptureMouse or Mouse.Capture in my C# WPF application?

I want to be able to access the coordinates of the mouse whether or not the cursor is over the window of my application. When I use Mouse.Capture(IInputElement) or UIElement.CaptureMouse(), both fail to capture the mouse and return false. What might be my problem? The cs file for my window is as follows: using System.Windows; using S...

the level of a treeview in WPF?

In a WinForms application, the level of a treeview is given by node.level What is the corresponding one in WPF? Thanks! ...

WPF Aero Glass DPI Setting Mismatch

I have a WPF application using Aero Glass. When using the application under a 120dpi setting the margins within my UI are not matching up to the margins I pass over to the DwmExtendFrameIntoClientArea API call. How would I get the systems DPI setting within .NET 3.0 so that I can correct the margin that I am passing to the DwmExtendFra...

What are the top 3 main concepts in WPF?

What are the top 3 main concepts in WPF that you need to understand in order to write good WPF code? ...

How to wait for a background thread/operation to complete in WPF UI code?

e.g. in Winforms I'd write... // on UI Thread BackgroundWorker workerThread = new BackgroundWorker(); workerThread.DoWork += new DoWorkEventHandler(LoadChildren); workerThread.RunWorkerCompleted += new RunWorkerCompletedEventHandler(OnLoadChildrenCompleted); while (workerThread.IsBusy) { Application.DoEvents();...

How to create Views in MVVM

I'm using MVVM in a WPF application. I want the least possible code to exist in the view's code behind. All Views and ViewModels are registered in dependency injection engine and my Views have dependencies to their ViewModel (injected via constructor). In one of the command handlers of ViewModel "A", I need to show View "B". What's the ...

WPF MediaElement video playback tearing

I'm trying to use the MediaElement control in WPF to play back video. It works great in Vista, but when I run it on an XP machine I get tearing in the display. It looks as if it's not using the vertical synch, and just updating the screen mid-draw. Anyone know how to fix this problem? ...