wpf

Binding a DynamicResource

I'm trying to use a MultiBinding as the ItemsSource for a ListBox, and I want to bind a couple of collections to the MultiBinding. The collections aren't populated until after the host control (a derivation of Page) has already been instantiated. Just after being constructed, I call a method that sets up some of the data for the Page, ...

ViewModel on top of XDocument

I am working on a WPF application which has a treeview that represents an XML. I load the XML on to the XDocument, then bind the TreeView to this object. Now using the MVVM pattern, I want to provide a ViewModel on top of XDocument. What are some of the things that I should implement in the ViewModel class. I am thinking of, Routed...

Variable opacity within a WPF application

My problem is: I have a Canvas which covers part of my Window. The Opacity of the canvas is set to less than 1, i.e. I can view the controls under the Canvas. What I would like to do is place a control, any control, say a Button, on the canvas and not have that Button semitransparent. Is this possible using WPF? ...

Exposing Multiple Databinding sources

I feel like I'm missing a fairly fundamental concept to WPF when it comes to databinding, but I can't seem to find the right combination of Google keywords to locate what I'm after, so maybe the SO Community can help. :) I've got a WPF usercontrol that needs to databind to two separate objects in order to display properly. Both objects ...

Copy Context Menu for ListView Control

What is the best way to add "copy to clipboard" functionality to a ListView control in WPF? I tried adding an ApplicationCommands.Copy to either the ListView ContextMenu or the ListViewItem ContextMenu, but the command remains disabled. Thanks, Peter Here is an xaml sample of one of my attempts... <Window.Resources> <ContextMenu...

Loose xaml referencing versioned assemblies

I have a unique development situation and would like some input from others. I have a situation where I need to load loose xaml files within a rich client application. A given loose xaml file may have references to an assembly not currently loaded in memory so the referenced assembly is loaded before the loading the loose xaml. The loo...

databind the Source property of the WebBrowser in WPF

Does anyone know how to databind the .Source property of the WebBrowser in WPF ( 3.5SP1 )? I have a listview that I want to have a small WebBrowser on the left, and content on the right, and to databind the source of each WebBrowser with the URI in each object bound to the list item. This is what I have as a proof of concept so far, but...

SQL 2 LINQ query (called by databinding) completely freezing WPF application

Earlier today I was hunting down a very weird bug... I finally traced it down to what seems to be causing the problem. The original report can be found here: original question The details have changed enough to warrant a new question. It would seem my application sometimes, NOT ALL OF THE TIME, freezes when it reaches the following LI...

WPF Dispatcher.Invoke 'hanging'

I have a somewhat complex WPF application which seems to be 'hanging' or getting stuck in a Wait call when trying to use the dispatcher to invoke a call on the UI thread. The general process is: Handle the click event on a button Create a new thread (STA) which: creates a new instance of the presenter and UI, then calls the method Dis...

WPF SaveFileDialog - Restrict Drives

How can I restrict the list of drive letters displayed by the WPF SaveFileDialog? ...

How do you manage huge and barely maintainable XAML files?

I'm having real difficulties with XAML files in Silverlight since they get very big very fast when using Blend. It just becomes a wall of text after only a handful of controls are added and animated. I'm hoping a better vesion of Blend will come out soon, so that our designers will never even have to see XAML. For now, though, that is n...

Load image from file and print it using WPF... how?

I'm looking for an example of how to load an image from file and print it on a page using WPF. I'm having a hard time finding good information about WPF printing. ...

Stop System.Windows.SplashScreen with WinForms from closing the app

I'm using System.Windows.SplashScreen to add a splash screen to my WinForms app (it has a lot of WPF controls, but the 'main window' is still a System.Windows.Forms.Form object). When the splash screen closes the whole app goes as well. Can I stop it taking the whole app with it? ...

Best practice when not implementing IValueConvert.ConvertBack

Just wondering what people think is the best practice when implementing an IValueConverter which does not have a meaningfull ConvertBack implementation (or one that is only to be used as OneWay)? Should it throw (and in that case what exception), return null or return some default value. Thoughts? ...

Dynamically Assigning the Style to the TabItem Control

Hi, I have a style defined in App.xaml file "tabControlStyle". How can I assign this style to my dynamically created TabItem control. TabItem item = new TabItem(); item.Header = String.Format("Item {0}", i); documentTab.Items.Add(item); ...

WPF find a control

I created a grid in procedural code on my WPF page. Now I want to reference that grid. Grid grid = (Grid)This.FindName("myGridName") does not work. Ideas? ...

WPF: Eliminate transparency between grid cells.

I have a Grid in WPF. The Grid has a transparent background (necessary) and each of the cells potentially has a different colored solid background, or maybe no background. When I put arbitrary content in these cells, when two adjacent cells both have colored backgrounds (same or different color, it doesn't matter) there is often (and unp...

WPF: Binding source is string with path to property

I am unsure if this is even possible, but I thought I would ask. First off, for my purposes, I require this to work in the C# portion and not the XAML part. This is what I have and it works: public partial class MyClass1 : Window { public MyClass2 MyClass2Object { get; set; } public MyClass1() { InitializeCompo...

How do I synchronize the SelectedItem of a ListBox?

I have this ListBox which is bound to an ObservableCollection. Each object in the list implements an interface called ISelectable public interface ISelectable : INotifyPropertyChanged { event EventHandler IsSelected; bool Selected { get; set; } string DisplayText { get; } } I want to keep track of which object is selected...

How to calculate the correct height for an auto-expanding textbox in Silverlight?

In my Silverlight app I want a multi-line text box to expand every time the user hits Enter. The difficult part is how to calculate the correct height based on the number of text lines. I have tried the following but the textbox becomes too small: box.Height = box.FontSize*lineCount + box.Padding.Top + box.Padding.Bottom + box.BorderT...