wpf

WPF View sets ViewModel properties to null on closing

Hi All I have an application where I'm displaying UserControls in a GroupBox. To display the controls, I'm binding to a property in the ViewModel of the main form, which returns a ViewModel to be displayed. I've got DataTemplates set up so that the form automatically knows which UserControl/View to use to display each ViewModel. When...

WPF: SelectedValue always null

In the following example SelectedValue of TabControl is always null. Why? <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib"> <DockPanel> <TextBlock Text="{Binding SelectedValue, ElementName=Tabs}" DockPanel.Do...

Refreshing UI with databind in WPF

I have a 3 layer deep treeview, -MAIN ->:SUB1 >:SUB2 >:SUB2 -X:SUB1 X:SUB2 SUB1 SUB1 where, > and X represent graphics denoting the status of that specific item (determined from backend). I'm using an Observable Dictionary to bind to this tree (and it has an ICollectionChanged event). The structure is like this: Obse...

Is there an XPath-like syntax in XAML that can get items out of a collection?

I have a Dictionary object in my ViewModel with key/values that translate words on the View. It is possible to get the language information as an XML object and then pick out the translated phrase with XPath, something like this: <TextBlock DataContext="{TranslatorDictionaryXml}" Text="{Binding XPath=/terms/term[key='edit']/value[@lang...

Staffing a WPF + Silverlight project

If staffing a "Silverlight / WPF business app" project would you include a team of graphic designers? ...

Best ways to convert XPS to PDF (and vice-versa)?

I have XPS documents being generated from XAML User Controls that act as templates. I want to convert the XPS documents into alternative formats, mainly PDF, programmatically with a .NET based API. What is the best way to do this? ...

WPF Databinding performance

I am building an wpf app using MVVM. I have viewModels the employ lazy loading like below: public class AssignmentsViewModel { List<AssignmentViewModel> _Assignments; public List<AssignmentViewModel> Assignments { get { if (_Assignments == null) _Assignments = new List<AssignmentV...

XAML or C# code-behind

I don't like to use XAML. I prefer to code everything in C#, but I think that I am doing things wrong. In which cases it is better to use XAML and when do you use C#? What is your experience? ...

using {DynamicResource {x:Static LocalizableTexts.OpenTextKey}}

I have been trying to come up with a better localization approach than LocBaml (wich sucks). And I though I could use something like {DynamicResource {x:Static LocalizableTexts.OpenTextKey}} (dynamicresource because my language could change at runtime). The only question is? How do I correctly create LocalizableTexts.OpenTextKey ? Is the...

Why would my application's window not show up when I run it?

Randomly and without warning (or apparent reason), VS 2008 decided to act as if debugging was working just like it always does, except for the fact that my application window never shows up on the screen. I’d been running my app from VS all morning, and I don’t see what I could possibly have changed that would make my window no longer sh...

WPF Create generic "Selector Tool" for multiple classes

Hi, the problem is pretty easy if you reduce it to one class. Given the following image, I want to create a simple two sided control, which puts items from one list into the other depending on a boolean value. EDIT: You can of course click on items in both lists, and the item switches to the other list. Also, a callback is called, in ca...

Databinding to a heterogeneous list

I have a WPF UserControl with a ListBox and ContentPanel. The ListBox is bound to a ObservableCollection that has apples and oranges in it. What is considered the proper way to have it setup so if I select an apple I see an AppleEditor on the right and if I select an orange an OrangeEditor shows up in the content panel? ...

WPF Interop & Dialogs

I have an existing WinForms application for which I'm now designing new bits in WPF. Things are going reasonably well and I have run into my first need for a dialog. I'd like to do the dialog in WPF. It appears as though I'm going to need to do a UserControl for the actual content and then host that content via a WinForms form with an...

WPF: How to Disable Combobox Items?

Hi! Is there a way to disable all but the first x items of a WPF ComboBox by accessing its items' properties via an Index? edit: ComboBoxItem DiffieHellmanItem = (ComboBoxItem)comboboxName.ItemContainerGenerator.ContainerFromIndex(i)); works ...

ObservableCollection PropertyChanged event

OK so I want to subclass ObservableCollection to add a property to it. Unfortunately the PropertyChanged event is protected. Basically I want to subclass it to have a SelectedItem that I can bind to for lists in my MVVM WPF app. Here's the skeleton of my class: public class SelectableList<T> : ObservableCollection<T> { public T Sel...

Are there any open-source free replacements for a richtextbox in WPF?

I have a requirement to create an application that will open up about 10 mb log files and highlight certain expressions. I thought using WPF and richtextbox will work, but the richtextbox rending time is unacceptable. Is there anything that has richtextbox like highlighting, but has better performance? There any other way to accomplis...

Setting PageOrientation for the Wpf DocumentViewer PrintDialog

Using the Wpf DocumentViewer control I can't figure out how to set the PageOrientation on the PrintDialog that the DocumentViewer displays when the user clicks the print button. Is there a way to hook into this? ...

How can I factor out a DataTemplate's binding in WPF?

I have a DataTemplate I want to reuse. The part I want to factor out is the binding, because it's the only thing that changes. My DataTemplate looks roughly like this. (There's actually quite a bit more to it, but I've taken out the extraneous stuff.) <DataTemplate> <TextBox Text="{Binding Name}" /> </DataTemplate> How can I reuse...

What's the problem with this code?

MyControl.Margin.Left = 10 ; // Error // "Cannot modify the return value of 'System.Windows.FrameworkElement.Margin' because it is not a variable" ...

WPF ListBox not updating with the ItemsSource

I have what I believe should be simple two-way databinding in WPF setup, but the listbox (target) is not updating as the collection changes. I'm setting this ItemsSource of the ListBox programmatically: lstVariable_Selected.ItemsSource = m_VariableList; And the ListBox is declared as follows: <ListBox Margin="5" Name=...