wpf

What do I have to change in my WPF databinding to get Listbox to show items?

I found this XAML in an example: <Window x:Class="TestDataTemplate123.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:TestDataTemplate123" Title="Window1" Height="300" Width="300"> <Window.Resources> ...

Why do I get "type reference cannot find a public type" on this databinding?

Why does the ObjectDataProvider not recogize "local:Customer" in this example? When I type <local: I get intellisense for "Customer" so it should work. I have no code-behind in this example. XAML: <Window x:Class="TestDataTemplate124.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http...

Does any one know of an exhaustive collection of WPF databinding examples?

It seems that every time I read an article on "how to do WPF data binding", it is done with some different variation, sometimes with DataContext, sometimes without, sometimes with Itemssource or both Itemssource and DataContext, there's also ObjectDataProvider, and you can have any of these in XAML or codebehind, or no codebehind and bin...

Who has the best answer for why DataContext and ItemsSource are not redundant?

In WPF Databinding, I understand that you have DataContext which tells an element what data it is going to bind to and ItemsSource which "does the binding". But e.g. in this simple example it doesn't seem that ItemsSource is doing anything useful since, what else would you want the Element to do to the DataContext except bind to it? <...

Access XAML object from code

Hello I created a UserControl in WPF: In Xaml: <UserControl x:Class="OutlookPanel.MailRelation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="300" Width="300" xmlns:graph="clr-namespace:MyPanel" > <DockPanel> <graph:Graph Name="theGraph...

How to get DataTemplate.DataTrigger to check for greater than or less than?

The following DataTemplate.DataTrigger makes the age display red if it is equal to 30. How do I make the age display red if it is greater than 30? <DataTemplate DataType="{x:Type local:Customer}"> <Grid x:Name="MainGrid" Style="{StaticResource customerGridMainStyle}"> <Grid.ColumnDefinitions> <ColumnDefinition W...

WPF ListView Inactive Selection Color and element font color

Hello, I'm able to set ListView Inactive Selection Color I used solution described in following question http://stackoverflow.com/questions/382006/wpf-listview-inactive-selection-color I need to change font color of selected inactive element, is there easy way to accomplish this? Thank You ...

Custom-drawing MapPoint maps in C#?

My application requires an on-drive map as there will be no internet access during operation. I've kind of settled on using MapPoint 2009, but the map 'style' really clashes with my overall UI look and feel. I'm wondering if there's some way to custom draw everything on the map (roads, labels, etc.)? It's crossed my mind that perhaps th...

How are you keeping your WPF resources organized on large projects?

On even the smallest WPF examples and prototypes I've been doing, the <Windows.Resources> begins to bloat fast. Putting it back into app.xaml puts it all out of my Windows and UserControls but it is hard to organize (the Visual Studio "XAML folding" feature is of no help since you just have a page full of the word "Style..."). In additi...

Update all bindings in UserControl at once

I need to update all the bindings on my UserControl when its visibility changes to Visible. Pretty much all my bindings are bound to the DataContext property of the user control so I'm trying to update the target of that binding: BindingOperations.GetBindingExpressionBase(this, UserControl.DataContextProperty).UpdateTarget(); But I ge...

Opening a new Window with InputGestures: main window steals focus

I have a simple UserControl which executes a routed command when user double clicks: <UserControl.InputBindings> <MouseBinding Command="someRoutedCommand" Gesture="LeftDoubleClick" /> </UserControl.InputBindings> Somewhere upper in the visual tree this routed command is bound to the procedure: <UserControl.CommandBindings> <C...

How do I implement a custom Brush in WPF?

Where can I find out enough info about how Brushes work to implement my own System.Windows.Media.Brush? I can handle all of the freezable baggage, but it's not really obvious what I need to override to get it to work. Yeah, so I didn't mean that I want to use a predefined brush. I want to extend System.Windows.Media.Brush, which is ...

WPF ComboBox custom Scrollbars

I'm looking for a resource on how to change the size (width) of the scrollbar presented by a combobox in WPF. ...

WPF ListBox Selection Color

Sorry if this has been asked before, but I couldn't find a solution to what I'm looking for in the related questions that popped up, or on Google. In my application I'm trying to recreate Words New Document dialog, list on the left of items and on the right an icon with text underneath. In Word it has the orange gradient when you mouse...

WPF Tooltip binding not updating

Good afternoon all, I have to work with a legacy Winforms application but I'd like to start migrating it to WPF. It doesn't have a tooltip control now so I'd like to use a WPF tooltip object. I create a single global instance of a tooltip object. I've bound the controls within it and my application sets the datacontext of the tooltip. I...

WPF Event: BitmapImage PropertyChanged: "Calling Thread Cannot access"

I'm trying to understand what it is about the following code that is perfectly happy with loading a text file and displaying its contents, but isn't happy with loading a BitmapImage and displaying it on a timer.Elapsed event handler. I understand it has to do with the UI thread. But why is this not a problem for the textfile example?...

Localization in WPF

I am starting a new application in WPF and I am curious how to handle Localization? In WinForms you can use resx strings for the UI text, how is this done in WPF? Is there a special binding syntax for binding to resx resources or is there a different way of doing this? Thanks! ...

WPF - What conditions must be met to use data binding in a custom control's content items?

I'm in the process of making a custom control -- specifically a pie chart. I want the markup to look something like this example: <c:PieChart> <!-- These dependency properties are never set --> <c:Slice Value="{Binding RedCount}" /> <c:Slice Value="{Binding BlueCount}" /> <c:Slice Value="{Binding GreenCount}" /> </c:Pie...

WPF DataGrid Take() not working for ItemsSource

Hi, I am trying to bind a DataGrid to an Array for testing purposes. As long as I am not trying to filter anything, the auto columns work nicely. As soon as I try to filter the array by .Take(5) or any other filter, the rows stay empty, and there are only thing horizontal lines. I think it may have something to do, with the "anonymous" ...

Databound WPF CheckBox eating exceptions on value set

I have a databound WPF CheckBox control that appears to be eating exceptions thrown by the corresponding property setter when the value is toggled in the UI. I know this can happen if I provide a ExceptionValidationRule on the Binding instance, but I double checked that the ValidationRules for the Binding instance has count zero. I als...