wpf

Convert WPF (XAML) Control to XPS Document

Can I take an Existing WPF (XAML) Control, databind it and turn it into an XPS document that can be displayed and printed using the WPF XPS Document Viewer? If so, how? If not, how should I be doing ‘reporting’ in WPF using XPS/PDF/etc? Basically I want to take an existing WPF control, databind it to get useful data into it and then m...

How to open a web page from my application?

I want to make my WPF application open the default browser and go to a certain web page. How do I do that? ...

Bind to a method in WPF?

How do you bind to an objects method in this scenario in WPF? public class RootObject { public string Name { get; } public ObservableCollection<ChildObject> GetChildren() {...} } public class ChildObject { public string Name { get; } } XAML: <TreeView ItemsSource="some list of RootObjects"> <TreeView.Resources> ...

Binding in a WPF data grid text column

I'm trying to build a data grid where one of the columns is a font name displayed in that font. Previously, I was working with a list box where I had defined the following template: <TextBlock Text="{Binding Path=Name}" FontFamily="{Binding Path=Name}"/> This worked just fine. So, I tweaked the data structure (Name became Font.Name) a...

Why can't I bind the WPFToolkit DataGrid ItemSource to DataTable?

In a Telerik control I was able to bind a DataTable directly to the ItemSource, but when I switched to the Codeplex WPFToolkit Datagrid <dg:DataGrid Name="theGrid"/> --- theGrid.ItemsSource = dt; I get this error: Cannot implicitly convert type 'System.Data.DataTable' to 'System.Collections.IEnumerable'. How can I bind the DataTabl...

Disposing WPF User Controls

I have created a custom WPF user control which is intended to be used by a third party. My control has a private member which is disposable, and I would like to ensure that its dispose method will always get called once the containing window/application is closed. However, UserControl is not disposable. I tried implementing the IDisposab...

WPF DataGrid is filled except when I use LINQ to filter its items

I've got a simple WPFToolkit DataGrid: <Grid> <dg:DataGrid Name="theDataGrid"/> </Grid> And in code behind a simple Contact class: public class Contact { public string FirstName { get; set; } public string LastName { get; set; } public Contact(string firstName, string lastName) { this.FirstName = firstNam...

In XAML how to say: default width and height for e.g. TextBox

So I'm coming at WPF from a HTML perspective. I just want to put a Textbox on my Window like this: <Grid> <TextBox Name="theName" /> </Grid> Turns out that the TextBox is then HUGE, covers the whole window. (!) Ok, that's not what I want, but I don't want to define the EXACT size either since I know height and width should be fl...

Implementing MVVM in WPF without using System.Windows.Input.ICommand

I'm trying to implement a WPF application using MVVM (Model-View-ViewModel) pattern and I'd like to have the View part in a separate assembly (an EXE) from the Model and ViewModel parts (a DLL). The twist here is to keep the Model/ViewModel assembly clear of any WPF dependency. The reason for this is I'd like to reuse it from executable...

How to use Array / Collection in WPF?

I have a program which has some Textareas / Labels these can be anywhere on the Window and in any order - however I want to assign them values from a List, Collection or Array so I want one label to read MyCollection(1) and another MyCollection(2) and so on - they are not always together or in the same order so a ListBox is no good - how...

How to bind custom object data to a ComboBox

I have a custom class Contact. I am trying to bind a List<Contact> to a ComboBox. But I can't get the right syntax/commands for the Windows.Resources part, e.g. the code below gives the error "The type reference cannot find a public type named 'List'", what do I need to fix in Windows.Resources to get this to work? My XAML: ...

WPF: ComboBox displays "(namespace).(classname)" instead of data

I want to get my ComboBox in XAML to bind to my List collection of custom objects in code behind. Currently the ComboBox lists for each entry "dpwpf.Contact" which is my {namespace}.{classname}. What do I need to put in the XAML to tell it to list out, e.g. LastName + FirstName? I know it's something like {Binding Path=... Value=...} ...

WPF/LINQ data layer design question

I'm working through the "Data Binding" chapter in Pro WPF in C# 2008. They have you set up this class: public class StoreDB { public Contact GetContact(int id) {...} public List<Contact> GetContacts() {...} } The idea is to call these methods, getting either a Contact or a List<Contact> and bind these to the appropriate contr...

How to store and retrieve multiple shapes in XAML/WPF?

Seem to be having a lot of problems doing what should be simple things with XAML / WPF - I have created some XAML-based images using shapes like Rectangle and Ellipse to create icons which I need other parts of my application to use - but I cannot seem to find out how to do this - I seem to be able to store a Canvas in the Resource Dicti...

Nested Frames (WPF) - How to make outer frame's nav bar ignore inner frame?

My application has a frame that is loaded/navigated when certain top-level buttons are clicked. The problem is, one of the hosted pages has a frame of it's own, and is messing with the outer frame's navigation bar (clicking back and forward navigates the inner frame, as well as the outer frame). Is there any way to have the outer frame...

WPF, Winforms, or something else?

We're about to embark on development of a new product. Our current product is a conventional client-server winform app written using VB.NET. Is WPF ready for a business application? From what I've seen, it seems like it's harder to develop a user interface with WPF than it is with Winforms. But I suppose speed comes with experience. ...

Windows dialog default heading.

Is there a built-in default Style or WPF element that would give me the equivalent styled text "Choose a connection option" below? I'm thinking that this Heading would change to match the OS (XP, Vista, 7) that the app is running in. ...

What's a simple ParentAdapter implementation look like?

I'm trying to write a ParentAdapter implementation; I'm interested in providing design-time support for some WPF controls I'm writing and this is how you manage custom logic for reparenting items to different container controls. I started small, with the notion of creating a StackPanel-derived class that would only allow Button elements...

CommandParameters in ContextMenu in WPF

I have a scenario where I have a WPF TreeView control that has an HierarchicalDataTemplate for its items. Now inside the HierarchicalDataTemplate, I have a Label and the Label has a ContextMenu with a menuitem for Delete. The Delete menuitem is binded with a Command called DeleteCommand which is a part of the class that has been set as t...

How do I implement an ajax-style loading panel in my wpf app?

I am calling a wcf service, so I'd like to display a spinner of some type so the user can see an operation is occuring. I'm wondering is somebody has some examples to look at. ...