wpf

WPF - styling comboboxes

Hi, I'm trying to style Comboboxes in WPF so that they are white, and have the same border as TextBoxes. I have the following style so far, but don't know how to set the border: <Style TargetType="ComboBox"> <Setter Property="Margin" Value="0,2,0,2" /> <Setter Property="VerticalAlignment" Value="Center" /> <Setter Property=...

Attached Property Changed Event?

Hello, ist there a way to get a change notification if an attached property changed? A simple example is a Canvas with a Rectangle in it. The position of the Rectange is set by using the DepenendyProperties Canvas.Top and Canvas.Left. I'm using an Adorner to move the Rectangle around by changing the Canvas.Top and Canvas.Left. <Canva...

How to block the UI during asynchronous operations in WPF

We have a WPF app (actually a VSTO WPF app). On certain controls there are multiple elements which, when clicked, load data from a web service and update the UI. Right now, we carry out these web requests synchronously, blocking the UI thread until the response comes back. This prevents the user clicking around the app while the data is ...

WPF - DataGrid Column Header Alignment

Hi all, I'm using the WPFToolkit DataGrid control and I wanted to restyle some of the column headers so that the header text is displayed vertically instead of horizontally (the data in the column is all numeric and therefore, not very wide, but the header text is long). So I created a DataTemplate to and tried to get the DataGridColumn...

WPF swing out an element

Say we have a standard WPF-application, and I want to show some UI-elements on the left side besides my main application window. Is there a way to go "beyond the borders" of the window and show a visual element with buttons on the left besides my main window? If there is, can you point me to a tutorial / video / hint how to accomplish ...

How to keep a local value from being set when a binding fails (so inherited values will propagate)

Consider the following scenario: I want to bind the TextElement.FontWeight property to an xml attribute. The xml looks somewhat like this and has arbitrary depth. <text font-weight="bold"> bold text here <inlinetext>more bold text</inlinetext> even more bold text </text> I use hierarchical templating to display the text, ...

Setting the background color of WPF TabControl inactive tabs

Is there a simple way to set the background brush of all inactive tabs in a WPF TabControl? I want to emulate the look of VS 2010 on a TabControl--the background color of the control's inactive tabs should match the background color of the window in which the TabControl is sited, so that you see only the text of the tab, and not the tab...

WPF-Window Topmost for own application only?

The Splashscreen/Loading-Window in my WPF application is set to Topmost="True". Now this windows in on top of all other windows even when you switch to another application (because loading will take some time). I don't want this kind of behavior. If I set Topmost="False" the window in not topmost at all. But If you switch back to my app...

WPF context menu bound to List<> dependency property

Im trying to make the contents of a List thats a dependency property show up in a WPF context menu. I have a class with the following dependency property, a list of Foo's (data holding class): public List<Foo> FooList { get { return (List<Foo>)GetValue(FooListProperty); } set { SetValue(FooListProperty, value); ...

Threading errors with Application.LoadComponent (key already exists)

MSDN says that public static members of System.Windows.Application are thread safe. But when I try to run my app with multiple threads I get the following exception: ArgumentException: An entry with the same key already exists. at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) at System.Collections.Generic....

WPF ListBox Data Binding Works in Designer but not Runtime

I have a maddening problem - I cannot get basic data binding to work even with copied examples. In the designer the listbox has 2 items but at runtime it's empty. <Window x:Class="BasicTables" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Basic...

How can I keep a WPF Image from blocking if the ImageSource references an unreachable Url?

I'm writing a WPF application and trying to bind an image to my view model with the following XAML: <Image Source="{Binding Author.IconUrl, IsAsync=True}" /> The problem is that the image URLs are defined by users and can often refer to images hosted on intranet web servers. When the WPF application is run remotely, it locks up while...

Image overlay on external window

I'm writing a C# WPF application that creates a video capture of the active window. What I want to do is overlay a transparent .png file in the corner of the active window while a capture is in progress so that all the videos created by my application are watermarked. If I have the IntPntr handle of the window I am capturing and an ima...

System.WIndows.Application static members are thread safe?

The Application static members are supposed to be thread safe: The public static (Shared in Visual Basic) members of this type are thread safe. In addition, the FindResource and TryFindResource methods and the Properties and Resources properties are thread safe.1 How much can we trust that statement in a multithreaded env...

Can WPF's MediaElement play a playlist of AVI files with seamless transitions?

The Windows Media Player control (sitting on a form) can be programmed to play a list of AVI files consecutively, but there is always a delay of a half second or so between the end of one file and the start of the next. Can WPF's MediaElement (or anything else) play a list of AVI's like this so that there is no noticeable delay between ...

Trying to get a better understanding of SelectedValuePath and IsSynchronizedWithCurrentItem

The following XAML produces a run-time Binding error when I click on an item in the ListBox: <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="WpfApplication1.MainWindow" x:Name="...

Why can't I set the Image Source in WPF app?

I'm just learning WPF. I'm using VS 2008. I've added an Image control to my XAML, and I added a GIF file to the project. If I use the XAML Designer's property panel to set the image's Source property, the drop-down list for the Source property contains the following: C:\Sample Project;component/pinHorizontal.gif There are several prob...

Is this slow WPF TextBlock performance expected?

Hi, I am doing some benchmarking to determine if I can use WPF for a new product. However, early performance results are disappointing. I made a quick app that uses data binding to display a bunch of random text inside of a list box every 100 ms and it was eating up ~15% CPU. So I made another quick app that skipped the data binding/...

How to trigger on bound item in WPF?

I want to activate a trigger if the bound items property ID is equal to a property in my custom control. But i can't use bindings in my triggers! How would i do this? ...

Getting the right WPF dispatcher in a thread.

Hi, In the constructor of an object i need to create a WPF mediaElement object: m_videoMedia = new MediaElement(); but the class can also be instantiated from a other thread so i need to use Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() => { m_videoMedia = new MediaElement(); })); But how can I get the right dispa...