xaml

Using GridSplitter in a Xaml file for both Silverlight and WPF

I have a Xaml file which is used in a project which can be built for both Silverlight and WPF. I want to use the GridSplitter control. However, this control is in different Xaml namespaces on Silverlight and desktop WPF. In WPF, the namespace is: http://schemas.microsoft.com/winfx/2006/xaml/presentation On Silverlight, it is: http:/...

Buttons in the corners?

I'd like to have 4 buttons one in each corner of a WPF/Silverlight window. But I want the stuff in the grid/window to be "behind" the buttons, as if they float on top. <Grid x:Name="ButtonRoot"> <Button VerticalAlignment="Top" HorizontalAlignment="Left" Name="bTopLeft" /> <Button VerticalAlignment="Top"...

Trouble applying a simple template

I'm having trouble applying a template to my checkboxes. I have the following template: <ControlTemplate x:Key="TriStateRed" TargetType="{x:Type CheckBox}"> <ControlTemplate.Triggers> <Trigger Property="IsChecked" Value="{x:Null}" > <Setter TargetName="path" Property="Data" Value="M 0 2.5 A 5 2.5 0 1 1 5 5 L 5 8...

WPF Button Image only showing in last control

Hello All! I am fairly new to WPF and am probably missing something simple here. If I have 3 controls, only the last control will show the OriginalImage that I specify. Any help would be most appreciated. Thanks Ryan Main Window <Grid> <Grid.RowDefinitions> <RowDefinition Height="200*"/> <RowDefinit...

Use AttachedProperty in Style in ControlTemplate

Here is my simple app: <Window x:Class="WpfApplication1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:app="clr-namespace:WpfApplication1" Title="Window1" Height="300" Width="300"> <Window.Resources> <Style x:Key="Test"> ...

Equivalent for TypeConverters for tags within property element tags?

Scenario: I'm trying to build my DataContext object tree for use as design time data. Great, awesome. Issue: I have a few types, some I control and some (such as DataRowView) that I don't, which cannot be simply new-ed up. I need some way to create instances of these types for use in my models. What I'd love is an equivalent of t...

Is there an easier way to typecast with unknown types?

Hi all. I am writing a function to recurse my XAML and add all the controls to a hashtable, with their names being the keys. Unfortunately it seems like I have to go through and list every possible type: void Recurse_Controls(object start) { string start_type = start.GetType().ToString(); if (start_type == "StackPanel") {...

WPF DataGrid Columns not auto sizing when not visible

I have a datagrid inside an expander that are initially closed. When the expander is opened, the columns are all at the minimum width. Is there a way to force a recalculation of the widths? Thanks! ...

Can a WPF ComboBox display alternative text when its selection is null?

G'day! I want my WPF ComboBox to display some alternative text when its data-bound selection is null. The view model has the expected properties: public ThingoSelectionViewModel : INotifyPropertyChanged { public ThingoSelectionViewModel(IProvideThingos) { this.Thingos = IProvideThingos.GetThingos(); } public Obser...

How do I alter the default style of a button without WPF reverting from Aero to Classic?

I've added PresentationFramework.Aero to my App.xaml merged dictionaries, as in... <Application x:Class="TestApp.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt; <Application.Resources> <ResourceDictionary> <ResourceDicti...

WPF XAML Bind Grid

I have a custom user control that is based on a Grid control. I have a ViewModel that exposes this as a property. I would like the XAML on the view to bind to this. I am sure this must be easy but I am quite new to WPF. How is this achieved? Many thanks in advance (Edited to add more info) Example of view without binding to ViewModel....

Having problem with treeview and Multilist Hierarchical data

I have the following 2 classes: public class DeviceGroup { public String Name { get; set; } public ObservableCollection<DeviceGroup> DeviceGroups { get; set; } public ObservableCollection<Device> Devices { get; set; } public DeviceGroup() { Name = String.Empty; Device...

What is the safest way of databinding to an element in another xaml file in WPF

I have an application which shows a Tree where can select nodes of the tree and add them to a list. To keep the code clean I have moved the TreeView into it's own UserControl(I use this tree in several places) and xaml file. To add a node to the list I have an 'add' button. However I want to gray-out this 'add' button when none of the tr...

How can I change the binding for template elements at runtime?

I've found few solutions which assumes that I have 2 or 3 binding objects(or data templates) - that is not good solution for me. Is there an easy way to do this? I can think of cycling through the visual tree and set the binding that way but still this solution doesn't look very neat. Thank you in advance. ...

Is there a way to edit a control's template based on the default template?

I'm trying to make just a few minor tweaks to the default template of a checkbox. Now I understand how to make a new template from scratch, but this I do not know. I did manage to (I think?) extract the default template via the method here. And it spat out: <ControlTemplate TargetType="CheckBox" xmlns="http:...

XAML - Binding Command to ItemsControl Contents

I have a UserControl with a ICommand-derived object as a Resource as follows: <commands:SetRegionContentCommand x:Key="SetContentComand"/> I then try to bind the command to the DataTemplate tag within an ItemsControl like so: <ItemsControl ItemsSource="{Binding Path=Items}"> <ItemsControl.ItemTemplate> ...

Conditional XAML

For easy of development I'm using a ViewBox to wrap all content inside a Window. This is because my development machine has a smaller screen than the deployment machine so using a ViewBox allows for better realisation of proportion. Obviously there is no reason for it to be there on Release versions of the code. Is there an easy method t...

Puzzle - Dynamically change data template control from another data template

I have a DataTemplate that contains an Expander with a border in the header. I want the header border to have round corners when collapsed and straight bottom corners when expanded. What would best practice be for achieving this (bonus points for code samples as I am new to XAML)? This is the template that holds the expander: <D...

WPF Conditional Binding. Button.IsEnabled to SelectedIndex >= 0

I want to bind a buttons IsEnabled property to (myObject.SelectedIndex >= 0).... isn't there a simple way to do this in the xaml (without having to do crazy things to any underlying objects)? I haven't really seen a good example. Honestly, I wish this was as easy as Flex 3 ... I.E.: <mx:Button enabled="{dataGrid.SelectedIndex >= 0}" .....

Binding Data Template element to property on sub-class

Hi guys, I have a class, for experiment sake call it foo() and another class, call it bar() I have a data template for class foo() defined in my xaml, but one of foo()'s properties is a bar() object such that foo() { Public string Name {get; set;} Public int ID {get; set;} Public bar barProp {get; set;} } and bar() ...