xaml

WPF: Use a different template depending on size and number of items

Hello, I'm trying to work out how I can alter the template depending on the size and number of items. This is very similar to the ribbon which dynamically changes depending on the size, or Windows 7 thumbnail of programs. In this case, it's an ItemTemplate of a ListBox and I want to reduce the size of the image or not display it, rathe...

WPF: Validation on a UserControl

Hi everyone, this is probably very simple, but I can't seem to figure it out... I'm currently using a UserControl to replace form fields to input text on a touch screen. This UserControl is essentially a Button displaying the current text and a pen icon, opening a separate screen keyboard window when pressed. It also needs to validat...

WPF, property in ValidationRule never set

I'm trying to bind a property in my DataContext to a property in a ValidationRule: public class ReleaseValidationRule : ValidationRule { // I want to bind a value from my DataContext to this property: public CheckboxViewModels ValidReleases { get; set; } ... } Based on this thread, I created the CheckboxViewModels class ju...

String manipulation in XAML property databinding for Hyperlinks

Is there an easy way to transform or format a string as part of WPF data binding? Suppose I want to create a WPF Hyperlink element based on a string tag. <Hyperlink NavigateUri="{Binding Tag}"> <Run Text="{Binding Tag}" /> </Hyperlink> But I need to transform the Tag first for the NavigateUri property to make it a true hyperlink ...

XAML/Blend dependant data binding

I want to create a listbox that'll be bound to XPath, relative to the other listbox's currently selected item. It's using XmlDataProvider for the data, and the XML file looks like this: <Programs> <Program name="..."> <Step name="..."/> <Step name="..."/> </Program> <Program name="another"> ... </Progr...

WPF: How to add 3D object from xaml file to my viewport3D?

I have viewport3D and I want to add multiple 3d objects defined in xaml files to this Viewport3D, but by default 3d object deffined in .xaml file comes already with viewport3D and I can not add it to my Viewport3D How I can use those 3D objects from .xaml files in my Viewport3D? I tryed to read xaml with XamlReader cast it to viewport3D...

Dynamatically create StackedColumnSeries by xaml

I create a stack chart and it has 2 seriesDefinition. It work fine. <chartingToolkit:Chart> <chartingToolkit:StackedColumnSeries> <chartingToolkit:SeriesDefinition DataContext="{Binding Path=CostDetail[0]}" ItemsSource="{Binding fees}" DependentValuePath="Fee" IndependentValuePath="PrjName" Ti...

XAML Bindings not working in custom EventTriggers

Hey all, I am having this really annoying problem... I have the following EventTrigger below: using System.ComponentModel; using System.Windows; using System.Windows.Interactivity; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; namespace App.Common.Actions { public class SoundEffectAction : TriggerAction<Framew...

WPF: Binding a ContextMenu to an MVVM Command

Let's say I have a Window with a property returning a Command (in fact, it's a UserControl with a Command in a ViewModel class, but let's keep things as simple as possible to reproduce the problem). The following works: <Window x:Class="Window1" ... x:Name="myWindow"> <Menu> <MenuItem Command="{Binding MyCommand, ElementNam...

How to set a TypeConverter on an attached dependency property in Silverlight ?

Hi, My goal is to be able to write this in XAML: <Grid> <Rectangle Fill="AliceBlue" myCore:MyTimePanel.BeginningDate="03/03/2010" /> </Grid> Problem : Silverlight XAML can't parse a DateTime from a string. So at runtime I have the XamlParseException "can't create a DateTime from that string". When I use a...

When IAttachedObject.Detach() (KeyTrigger.Detaching()) method is actually called?

Let's say I have a Silverlight user control with a textbox: <TextBox> <ii:KeyTrigger Key="Enter"> <!-- something here --> </ii:KeyTrigger> </TextBox> I inject my user control into root content control: root.Content = new MyUserControl(); Now I know that KeyTrigger will be hooked up to TextBox when "Loaded" event of MyUser...

VS2010 WPF - Can I create a menu with menu items just via the UI (not editing XAML?)

Just trying to drag my first Menu control onto a WPF application in VS2010. Is there a way to (via the VS2010 UI) setup the menu items etc? Or does one have to jump into the XAML to do this? Also it seems like the Menu control, after I drag it onto the window, exists at the top of the Window. However I was expecting it to be rend...

windowless wpf application example?

Any advice or links or sample application (for VS2010) re how to develop a "windowless" WPF application? That is the ones that look quite modern and don't seem to have the historical window chrome around the edges - they seem to have rounded edges etc... ...

Silverlight grid (panel) 2 columns 50%/50%

Hello I want a silverlight grid layout panel. The width should be 100%. There should be 2 columns that both take 50%. In the columns there should be buttons that take 100% of the column cell.. Somehow I mess it up all the time and cannot find a way to do this. Gridpanel is not a must... Stackpanel or whatever is fine too.. One more th...

How can I bind a data inside a style?

This XAML tag doesn't work: <Label Content="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}" /> in this XAML code: <Style x:Key="textBoxStyle" TargetType="{x:Type TextBox}"> <Style.Triggers> <Trigger Property="Validation.HasError" Value="True"> ...

XAML binding on click

Continuing from my last question, I'd like to know how can I bind when a button is clicked (can this be done through pure XAML?) - or more simply, how can I do XAML-like binding through C# code? EDIT: The previous question containing info: I want to create a listbox that'll be bound to XPath, relative to the other listbox's currently s...

Custom styled listbox - how can I keep the style for a selected item?

I have a styled listbox. Listbox items change color when hovered over and when selected. Hover and select work fine. But when selecting an item then taking the mouse off it and coming back to hover over it causes it to go back to hover/unselected state even though it is still selected. How can I keep the listboxitem in a "selected" visua...

WPF/XAML Databinding Question

Hello, I am writing an application in C#/WPF and am trying to figure out how to databind the width of the grids column definitions to a fraction of the screen width. Is this possible? Essentially I want something like this: Grid = 2x2 Row 1 Height = 2/3 of screen height Row 2 Height = 1/3 of screen height Row 1 Width = 2/3 of screen wid...

How to bind with dynamic resource and specifying a path

I want to bind to a resource (DynamicResource) and access properties on that resource, but is there a way to do that? (I want to visualize the default values from constructor in the xaml editor in visual studio. Those cannot be seen when referencing an object through DataContext nor through a property added on my Window class...) Not...

[WPF/XAML] Add an event on ListBoxItems build with ItemTemplate

Hello, I have a ListBox like this : <ListBox DataContext="{Binding UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding UpdateSourceTrigger=PropertyChanged}" ListBoxItem.Selected="ListBoxItem_Selected"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> ...