wpf

WPF combobox binding

Update: I've included some diagnostics in the SelectedValue property (diagnostics:PresentationTraceSources.TraceLevel=High) and I think I can see the issue, although I do not know how to fix it. The diagnostics show System.Windows.Data Warning: 76 : BindingExpression (hash=16001149): TransferValue - got raw value '3' System.Windows...

How to make ItemsControl choose different templates depending on run-time type.

I have a xaml page that has an ItemsControl control on it. ItemsControl is bound to Guests which is ObservableCollection. Guests collection can have objects of two different types: USGuest and UKGuest, both inheriting from Guest. Is it possible to make two (or more) templates for ItemsControl and make it automatically choose between them...

WPF MenuItem : Mix databound items and static content

Hi there, I'd like to build an MRU menu that has the following structure: File +=>Recent Files +=> Doc1.txt +=> Doc2.txt -separator- +=> Clear entries This being MVVM, my mru list is databound to the View Model. Because I want to add the separator, and I don't fancy inserting the separator and the clear entry action in th...

WPF Datagrid template removes ability to resize columns

How come whenever I override the default template for a DataGridColumnHeader it can no longer be resized by the user even though CanUserResizeColumns is set to true for the datagrid? Is there something that I need to add to the template to restore this functionality? Here's my template xaml: <Style x:Key="ColumnHeaderStyle" TargetType=...

Can I share the TreeView control with Silverlight and WPF?

I would like to use the WPF and Silverlight toolkit's TreeView control, but have it be in the same xaml file that I share between 2 projects as a link. In silverlight, the class is in the System.Windows.Controls.dll and in WPF it is in PresentationFramework.dll. So for my xaml namespace, they need to be declared differently which cause...

WPF Label Design

I have a label in WPF which I want to restyle so it has rounded corners. I have the below code already: <Style TargetType="{x:Type Label}"> <Setter Property="Background" Value="Red"/> <Setter Property="Margin" Value="2,2,2,2"/> <Setter Property="BorderThickness" Value="2"/> <Setter Property="BorderBrush" Value...

WPF Change color in Xaml based off code behind property

I am trying to change the color of my label based off an enum set in xaml. I can not get the colors to update. Any help would be great. Thanks! <UserControl.Resources> <!-- Normal --> <SolidColorBrush x:Key="Normal_bg_Unselect" Color="#FF1A73CC" /> <SolidColorBrush x:Key="Normal_fg_Unselect" Color="#FF72BAFF" /> <Soli...

Dictionary<string, List<int>> to WPF GridView

I would like to bind a Dictionary<string, List<int>> to a GridView in a ListView and I'm not having much luck. I've looked at this question: wpf-binding-dictionarystring-liststring-to-listview-listbox-how, and this question: dictionary-binding-to-listview But I'm not sure how to take their code and make it work for me. Here's what I'v...

How to assign the selectedItem of a WPF combo box to a variable

Hello all, I am hoping you can help me unravel an issue I am having with the use of a combo box. Within my project I need to consume values from one collection and have these items display within my combobox . At this time I have built an observable collection that simply contains different involvement types public ObservableCollection...

Designing a WPF user control with DependencyProperties and a backing object

I have an object in my business layer (let's call it Car for example's sake), and I have created a UserControl (CarIcon). The user control has a property that is a Car object and when the Car object is set it calls a method that configures the various properties of the user control. Now I am rewriting it to use dependency properties so...

WPF Custom Control - How do you bind a listbox from a static ObservableCollection?

I'm not sure how to go about this exactly. I have a static ObservableCollection in the NameField.cs class. I just have no idea how to bind it to the listbox. Should I not be using a ListBox? Should I be using a DependencyProperty? Should I be exposing the ObservableCollection through a property or by public? I'm not sure what to do h...

Why DataGrid in WPF 4.0 doesn't show Data?

So i Got a tmplist of ObservableCollection in which i got few elements. I connect it to the ItemsSource of DataGrid in WPF 4.0 and it doesn't show anything. Doesn't add any colums. If I add breakpoint I can see that the "ItemsSource count equals quantity of tmplist elements, but the Columns count equals 0. Why is that? Here is some code...

WPF Populate combo box with multi-table data

Hello: I'm working on a simple WPF example and wanted to expand the example but I'm struggling, I'll explain some background first. I have three tables, people, addresses, and countries. As expected people live at an address, and addresses are located in a specific country. I'm currently working through using a combo box as a lookup t...

Binding to Canvas

I have a canvas property in my class and I was wondering if it's possible to bind that to a canvas in xaml? How would the databinding work in the canvas? <Canvas ItemSource="{Binding ClassCanvas}" /> ...

Creating Non-stroked Region in C# StreamGeometry Xaml markup

I am looking for a way to create non-stroked regions for a StreamGeometry in xaml. In other words, I want to know if it is possible to recreate the following code (taken from msdn) with the StreamGeometry Xaml markup syntax. StreamGeometry geometry = new StreamGeometry(); geometry.FillRule = FillRule.EvenOdd; using (StreamGeometryCont...

Why this code doesn't work? :(

<dg:DataGrid Name="gridList" AutoGenerateColumns="False" ItemsSource="{Binding ItemsInTable}" HeadersVisibility="Column" > <dg:DataGrid.RowDetailsTemplate > <DataTemplate x:Name="ItemDetails" > <Border HorizontalAlignment="Stretch" CornerRadius="5" Background="Azure" > <Stack...

Can I replicate the IsStroked property for a PathSegment in Silverlight 4?

In WPF it is possible to use the IsStroked property of a PathSegment to make the Segment invisible, I'm looking for a way to replicate this behavior in Silverlight, which doesn't have this property. Is this possible? [EDIT] I'm looking for a way to do this in code-behind, not in Xaml. ...

SendPropertyChanged of public field with private field

I would like to send a property changed event of the public property everytime the private member is set. How would I do this? private string _imageName; public string ImageName { get { return _imageName; } set { _imageName = value; SendPropertyChanged("ImageName"); } } protected virtua...

WPF ScrollViewer

Hi, I was wondering if there is anyway to check if the up arrow or the bottom arrow of a wpf scroll viewer is clicked. I am trying to do it within a wpf textbox but, I want it to snap to the next line of a text instead of displaying partial text. So, the way for me to do this is when up/ or down is clicked. i would say textBox.lineup...

Ideas for alternative context menu layouts

I'm trying to, find / come up with, a cool alternative to the old trusty rectangle-list-o-buttons context menu. I have seen some suggesting laying the item out circles in a circle, and they call it a pie-menu. And as you click a circle, it expands to have items around it etc. (http://www.emphess.net/2008/05/04/a-menukiller-control-draft/...