xaml

WPF: How do I create a button "template" that applies a style & has an image in it?

There are multiple places in my WPF application where I need a button that looks & feels like a regular button, but: It shows a specific icon on it (defined as {StaticResource EditIcon}) It applies a style (defined as {StaticResource GrayOutButtonStyle}) I would prefer to define these attributes in a single location, rather than repe...

How can I use VisualStates in a ChildWindow?

Is there any way to use the VisualStateManager with my ChildWindow subclass? Calls to VisualStateManager do nothing, and the googling I did implied the only way to achieve this is with manual calls to Storyboards. That's so much sloppier and prone to error. Has anyone found a way to achieve it? Updated with example code. To use it, just...

Alternative XAML authoring tools?

If I am writing XAML, do I have to use Expression Blend or Visual Studio, or are there alternative tools around? ...

How to set property in IDataErrorInfo validator from Xaml

When using IDataErrorInfo in WPF is there a way to pass parameters to the validator. For instance I have a DueDate Datepicker. When validating for a new task I want to restrict the date allowed to today or later but when editing I need to allow for DueDates before today since a task can be edited that is past due. My DatePicker in Xaml ...

Using bindings to control column order in a DataGrid

Problem I have a WPF Toolkit DataGrid, and I'd like to be able to switch among several preset column orders. This is an MVVM project, so the column orders are stored in a ViewModel. The problem is, I can't get bindings to work for the DisplayIndex property. No matter what I try, including the sweet method in this Josh Smith tutorial, I ...

help with grouping and sorting for TreeView in xaml

I am having problems getting my head around grouping and sorting in xaml and hope someone can get me straightened out! I have creaed an xml file from a tree of files and folders (just like windows explorer) that can be serveral levels deep. I have bound a TreeView control to an xml datasource and it works great! It sorts everything alp...

Silverlight: loading controls based on radioButton selection

I am working in SL version 2.0 I have 3 radio buttons in a group and 3 user controls that I want to load based on the selection of the radio button. How can this be done? What options do I have? I was thinking about adding the user controls in the same xaml file as the radio buttons, and make them all invisible. Then on the code behind...

How can I apply a custom sort rule to a WPF DataGrid?

When the user does a column sort in my DataGrid, I want all null or empty cells to be sorted to the bottom, rather than the top. I wrote an IComparer<T> that makes sure blanks are always sorted downward, but I can't figure out how to apply it to the columns of my DataGrid. Note that the initial sort of the DataGrid, which I'm doing with...

[WPF/XAML] - Change DatePicker style based on SelectedDate

Hi all, First question here. Anyway, here it goes: I have a XAML Windows with a lot of DatePicker controls (DatePicker from the WPFToolkit on CodePlex). Every DatePicker has a default Value of 1/1/1990 and if no other date is selected, I want (or rather my boss :-) ) to display the Text in gray italic and not in Black. Thus, it makes it...

Having an issue with CoverterParameter Binding in silverlight

Hi everyone, I am having an issue with the xaml parser not liking my binding statement but i cannot see anything wrong with the statement. Invalid attribute value {Binding VehicleSpeed, ConverterParameter={Binding InMiles}, Converter={StaticResource SpeedConverter}, Mode=TwoWay} for property DataMemberBinding VehicleSpeed and InMi...

WPF DataTrigger not firing when Application style applied???

Hi guys, Any help on this problem would be greatly appreciated as I have been looking around all day for answers surrounding this area! I have applied a global style to my WPF application by adding in a merged dictionary to the App.xaml. This has applied the style across the application like intended but there are a number of things t...

Using Unicode characters in C# controls

I want to add the Greek letter omega (U+03A9) to a label I've placed on the form. I've already switched the encoding of the form, but how do I set the content of the label such that an omega appears and not UTF char code. So taking this XAML <Label Height="25">U+03A9</Label> I want the U+03A9 to be converted to an omega in the code ...

Binding to the selected item in an ItemsControl

I created a custom ComboBox as follows: (note, code is not correct but you should get the general idea.) The ComboBox contains 2 dependency properties which matter: TitleText and DescriptionText. <Grid> <TextBlock x:Name="Title"/> <Grid x:Name="CBG"> <ToggleButton/> <ContentPresenter/> <Popup/> </Grid> </Grid> I want...

Need a way to center a TextBox under a Canvas in WPF Designer

I'm new at using the WPF Designer in VS2008 and I know very little about it right now. I'm trying to learn via experimentation. Below is my XAML (generated mostly by VS): <Grid> <Grid.RowDefinitions> <RowDefinition Height="478" /> <RowDefinition Height="64*" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions>...

How do I bind element widths where "Auto" width behaviour is required?

I wish to have a set of elements have the same width, I can not simply put them in a grid as this is a content control and the elements being bound is unknown. As a simple example, how do I bind all widths of the first child of each stack panel together along with the second element. <StackPanel> <StackPanel Orientation="Horizo...

Resizable WPF Grid inserts blank lines between rows and columns depending on actual size

Hello, I have a Grid displaying rectangles. The grid can be resized and is supposed to display adjacent rectangles without any gap. However, depending on the actual size of the grid, blank lines appear between the rows and columns of the grid. I guess this is to make up for sizes where the width isn't a multiple of the number of column...

How to use DisplayMemberPath to show an item in a specific column

I have a ListView with several GridViewColumns (Title, Start, Due). So how can I bind an object with a string Title, datetime Start, and datetime Due. In procedural code I have already stated: lvwFill.ItemsSource = assignments.ListAssignments(); //Returns a List<Assignments> So now my XAML is: <ListView x:Name="lvwFill">...

WPF Change style of surrounding border on mouse over

I have a Grid with a Border around it. Upon mouse over on the Grid, I want to change the style on the Border. How would I go about doing this? This is what I've tried, without any success so far: <Border Name="Border" BorderBrush="Transparent" BorderThickness="1" CornerRadius="2"> <Grid> <Grid.Style> <Style Targe...

WPF - Binding to current item from within group header style

Hi, I'm something of a WPF noob so please take it easy on me ;-) I am trying to create a grouped DataGrid (WPF toolkit version). I have successfully created the data source, the DataGrid itself, the required CollectionViewSource and the Style for the group header (which uses an expander). I want to group by a property called 'Assign...

Error in XAML: Type reference cannot find public type

In my WPF application, I have a TreeView control defined in my XAML. I've added a TreeView.Resources section that looks like this: <TreeView.Resources> <HierarchicalDataTemplate DataType="{x:Type local:FileGroup}" ItemsSource="{Binding protXMLFiles}"> <TextBlock Text="{Binding Path=groupName}"/> </HierarchicalDataTemplat...