xaml

How to change a WPF window backgroud with a data trigger?

I want to change the background color of our apps main window when a property changes. We have a business date that can be changed and I want to change the window background when it has changed from expected. I've set up a property to tell this. But can I set a style datatrigger on a window that changes itself? Or would I need to do ...

Implementing multiple screens in an Application

Weird question, but one that puzzles me a bit. In the old days when we had Terminals and DOS, applications generally only had one "window", and that was a fullscreen one. When people switched functions, there was no concept of opening a new window, but instead the content of the main window was overwritten. So there was only one main win...

databinding to XML in XAML: How to append new XmlNode?

Hi, all I found so far about databinding to XML always only seems to be binding to a fixed XML structure. Would be nice, if anyone could point me in any direction, everything I tried so far seems very awkward. This is what I would like to do: Binding the Checked state of a Checkbox to a node within the XML. So it is checked if this sp...

Silverlight XAML Binding -- Decimal to Double

I've got some Columns in a DataGridView that have their Binding property set to something like the following: Binding="{Binding NetPrice}" The problem is that this NetPrice field is a Decimal type and I would like to convert it to Double inside the DataGrid. Is there some way to do this? ...

How can I desaturate selected rows when DataGrid is out of focus?

The normal convention for UI controls is for selected text, items, or rows to be brightly colored (e.g., bright blue) when the parent control is in focus and desaturated/dim (e.g., pale blue) when the control is out of focus. In contrast to the ListView/GridView, the WPF DataGrid control does not follow this convention by default. Selec...

Is there a XAML/WPF/Silverlight style guide?

From .NET Rocks! Show #488: Richard Campbell: "In the GDI world we got a document from Microsoft that said you will build your apps in battleship gray and here's now they should look: File goes here and Help goes here, and we all got that as developers. There's no book like that for WPF. There was this idea I've got ...

Need themes for the WPF Toolkit controls (espeically DataGrid)

I just downloaded the nice themes collection from the Codeplex WPF Themes site. I like the WhisterBlue and BureauBlue themes a lot, but neither contain any styles for the new controls included in the WPF Toolkit (DataGrid, DatePicker, and Calendar). It seems like someone out there must have extended the themes to cover these controls, b...

How to bind a ComboBox to generic dictionary via ObjectDataProvider

I want to fill a ComboBox with key/value data in code behind, I have this: XAML: <Window x:Class="TestCombo234.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:TestCombo234" Title="Window1" Height="300" Width="300...

Is there a way to make a XAML textbox validate on int or double without custom ValidationRules?

I have some XAML textboxes that need to allow nothing but double and some that need to allow nothing but int. I could use Binding.ValidationRules with all its code behind, triggers, styles as described here, but isn't there a way for these simple validations to use an attribute something like this, just so nothing but that type can be ...

ComponentResourceKey as DynamicResource problem

Hi, I'm seeing some unexpected behavior using ComponentResourceKey. The problem came up because I was using names used in the SystemColors class. Consider the following code: First I expose a ComponentResourceKey in a as a static property: public enum ColorKeys { ControlColor } public class MyColors { public static Compon...

How do you port a theme from Silverlight to WPF?

It's "easy"! I just came across this blog post by Rudi Grobler that says it's "easy" to port a theme from Silverlight to WPF. Unfortunately, he doesn't say how to do it. Download and install I have installed both the WPF Toolkit and Silverlight Toolkit from Codeplex. I also went and dug up the source code for the theme I'm interest...

Check / Uncheck a ToggleButton From a StoryBoard in WPF

I have an animation that expand / collapse some StackPanels, in the window there are some ToggleButtons that must be unchecked when the StackPanel is collapsed. I have the animation like this: <Storyboard x:Key="cmdUnchecked"> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="StackPanel1" Storyboard.TargetPro...

Listing all Validation.Errors in a single WPF control?

I'm trying to find a simple way of binding a single control (eg. TextBlock or ListBox) to list all the validation errors on a WPF form. Most source code examples I have been able to find just bind a control to (Validation.Errors)[0].ErrorContent which only shows a single validation error. I'm currently using ValidationRule classes, thou...

WPF bind DataContext in xaml to ViewModel in code

Hello, i have this simplified version of my app in XAML: <UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:uc="clr-namespace:myApp.MyControls" x:Class="myApp.View.MyIte...

[XAML] Using ObjectDataProvider as binding source gives SQL error

Hi I have a weird problem that i can't figure out a solution for: I've made a little WPF app written in C# that uses an attached SQL Server Express .mdf database which i then manipulates through LINQ. I have a ListView on the form which datacontext is set to .DataContext = dr.FindAllBuyOrders() which returns an IQueryable BuyOrder obj...

how to express this xaml combobox data-binding in c# code

ItemsSource="{Binding Source={StaticResource stringResources}, Path=MyProp}" I tried and got so far but I don't get it compiled: comboBox.ItemsSource = new Binding { Source = new StringResources(), ElementName = "MyProp" }; comboBox.DisplayMemberPath="Value"; comboBox.SelectedValuePath="Key"; It says that it cannot convert Binding t...

Why isn't Expression Blend rendering my User Control? It's only showing XAML.

I'm opening valid XAML within my VS2008 solution in Expression Blend 3 and it is only showing XAML when I try to open individual XAML files. My solution/projects all build and run correctly. When I go to View -> Active Document View the Design View, Split View and XAML View options are all grayed out... which doesn't make much sense. I...

Why would a TextBlock with DropShadowEffect show a solid black background on one XP machine?

We have a WPF application in which we have the following XAML: <TextBlock x:Name="HeaderRightSubtitle" HorizontalAlignment="Left" VerticalAlignment="top" FontSize="10" Foreground="#FFFFFF"> <TextBlock.Effect> <DropShadowEffect Color="#FFCACACA" ShadowDepth="1" Opac...

Move focus in response to keyboard events in XAML

I've got a WPF view with two textboxes. I'd like to automatically move focus forward from the first textbox to the second when the user hits the down arrow on the keyboard exactly like Tab does. It seems like I ought to be able to do this 100% declaratively, but for some reason the commands I thought would do this don't seem to do anyt...

Pre-sorting a DataGrid in WPF

I have a DataGrid in WPF app with several columns, including a Name column. If the users switches to a particular view, I want the data to be pre-sorted by Name (and I'd like a sort arrow to appear in the Name header just as if the user had clicked that header). However, I can't find the expected properties to make this happen. I was loo...