xaml

WPF Designer exception while trying to edit UI in Visual studio 2008

I have VS2008 with .net 3.5 SP1 installed on my machine, I have written one simple application with two listviews and databinding, My application compiles fine and I am able to run it, but when I try to open designer to edit controls, I get following error. I am not getting why this is happening. Any idea...see xaml below this error mes...

Any way to make Intellisense work, when opening a cs file that's not part of the project?

What we ideally need is, to know how Microsoft handles XAML generated code (Those *.g.cs files). If you goto a XAML code behind, intellisense will work even if the *.g.cs file is not part of the project!! Context: In a custom VS package, we need to have some logic to open a CS file (with out making it a part of the project) in the V...

Need simple example of WPF binding Objects to Listbox with LINQ

The following example successfully binds objects with a list box to display them. However, I would like to create all the objects in one class and then from another class query them with LINQ to fill my XAML Listbox, what would I need to add this example: XAML: <Window x:Class="WpfApplication15.Window1" xmlns="http://schemas.mi...

What's wrong with this ContentTemplate?

I'm getting an error for this content template within a style: "Must specify both Property and Value for Setter." Aren't I doing that? <Style x:Key="LinkButton" TargetType="Button"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="Button"> <ContentPresenter/> </ControlTemplate> ...

Dynamically resizing a window in Xaml

Is there a way for me to have the Window of my WPF application resize dynamically with the content? I tried setting the width and height to auto, but no go. ...

XAML - What's the point of (typing) it?

I am currently looking into learning WPF and Silverlight. So far I have been developing in Delphi and C# (Winforms). While looking at some books about WPF and watching some introductory videos online, I am getting the impression that this XAML thing is quite a step backwards in terms of efficiency and usability (for the developer). Espec...

XAML: why is button on top when I clearly said to go on bottom?

In XAML, I want the button to go on the BOTTOM of the red rectangle. I clearly say: "HorizontalAlignment="Right" VerticalAlignment="Bottom" It goes to the right but stays on the top. Why is that? <UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/x...

Converting a WPFToolkit DataGrid from 1D list to 2D matrix

Hello - I am wondering if anyone has attempted the following or has an idea as to how to do it. I have a WPFToolkit DataGrid which is bound to an ObservableCollection of items. As such, the DataGrid is shown with as many rows in the ObservableCollection, and as many columns as I have defined in for the DataGrid. That all is good. Wha...

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...

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...

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...

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=...} ...

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...

Two way data binding in a GridView

We have an app that uses simple one way binding with a GridView to display some data. Well, now we need to allow the user to change some of that data, so I've been trying to get two way data binding to work in the GridView. So far everything displays correctly, but editing cells in the GridView seems to do nothing at all. What am I messi...

How to properly bind a ListBoxItem in WPF ?

I have a listbox and I want to iterate over a collection of Bars in my Foo-object. <ListBox DataContext="{Binding Path=Foo.Bars}" > <ListBox.Items> <ListBoxItem> <ContentControl DataContext="{Binding Path=.}" /> </ListBoxItem> </ListBox.Items> </ListBox> This is the datatemplate I want to use. <Dat...

Set TextBlock to be entirely bold when DataBound in WPF

I have a databound TextBlock control (which is being used inside a DataTemplate to display items in a ListBox) and I want to make all the text in the control bold. I can't seem to find a property in the properties explorer to set the whole text to bold, and all I can find online is the use of the <Bold> tag inside the TextBlock, but I ca...

Blurred/Pixellated display of DataTemplate for ComboBox in WPF

I have a DataTemplate giving items for display in both a ListBox and a ComboBox. The window I have created looks like this: The question I have is why the DataTemplate in the ComboBox is blurrier or slightly more pixellated than the display in the ListBox. It is quite difficult to see on the screenshot, but it seems more noticeable whe...