xaml

Bind Collection to StackPanel

I want to take a collection of objects and bind it to a StackPanel so basically if the collection has 4 elements, inside the stack panel that should produce 4 buttons lets say. I tried this...But I dont think its the correct approach anyway. I used DataTemplated to do this type of idea in the past.. please correct me if I am wrong. Her...

Binding MenuItem property (IsEnabled) to combobox property (SelectedIndex) in same control

Hey all, I've spent a good portion of my day researching this; I'm curious if it's possible to do simple binding fully in XAML, without the need to implement INotifyPropertyChanged in the code behind. Ironically, in the amount of time I've spent researching this I could have just done it in the code behind 5 times over. I've come acro...

Silverlight: Can I set an event to a base class event handler in XAML?

I have created a custom user control to use as a base class for some maintenance functions. I would like to be able to wire up some events to handlers defined in the base class. I can do this manually in the code behind but would like to assign them in XAML. Is this not possible? <src:CustomerMaintenanceControlBase x:Class="ProjectMana...

Template for Control Effect

I was wondering if there was a way to make a template for an effect so I can apply it to all my controls. That way if i was the effect to be modified, I only have to change it in one location... Let's say I have: <Button Content="Foo" Height="50" Width="50" > <Button.Effect> <DropShadowEffect BlurRadius="10" Color="Black" Opac...

Controlling multiple Button's Properties within ViewModel

I have 18 Buttons within a Uniform grid on my main WPF window. I need to modify many of the Button's Properties and Command both when the program loads and during operation. In other words, when the program first starts, a configuration is selected that affects the layout. Later that could change further depending on how the program o...

Binding a UIElement's Name

Is there any way to use binding to set the UIElement's name? I always get a runtime exception saying System.Windows.Markup.XamlParseException: AG_E_UNKNOWN_ERROR <Button Name="{Binding myName}" Content="{Binding myName, Mode=TwoWay}" /> If I take the binding off for the Name property the control works and the Content property is bin...

WPF4 DataGridHeaderBorder in a xaml Style

Making a separate question, related to comments on the answer to http://stackoverflow.com/questions/2481946/wpf-4-what-happened-to-datagridcolumnheader It appears I can use DataGridHeaderBorder in a UserControl, stand-alone in a ResourceDictionary, but not in a Style's setter of a Template. <ResourceDictionary xmlns="http://schemas.mic...

Setting tooltip to equal content

I'm trying to set a data grid's cell's tooltip to be equal to the text inside of a TextBlock in that cell. What I have so far is this: <Style x:Key="CellStyle" TargetType="{x:Type DataGridCell}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="DataGridCell"> ...

binding an image source in XAML

I am trying to bind an image source to my XAML through c# this works <Image Source="images/man.jpg"></Image> this does not work <Image Source="images/{Binding imagesource}"></Image> where imagesource is a string variable in the c# file of this xaml and is being set equal to "man.jpg" ...

Centering text in passwordBox in XAML

I'm trying to center the text in a PassWord box: In Blend the Text properties for alignment are all disabled. Is there another way to do this? Thank you for your help. ...

Move down overflow contents in horizontal stackpanel

I have a list box in expander: <ListBox ItemsSource="{Binding MySource"> <ListBox.ItemTemplate> <DataTemplate> <RadioButton Content="{Binding MyContent}" /> </DataTemplate> </ListBox.ItemTemplate> <ListBox.ItemsPanel> <ItemsPanelTemplate> <StackPanel Orientation="Horizontal" />...

How to keep a nested grid square without using ViewBox?

This is similar to how-do-i-keep-aspect-ratio-on-scalable-scrollable-content-in-wpf, with the following differences: I'd like to avoid side-effects of the ViewBox - while the grid should resize when the container resizes, some of the grid content should keep their sizes (buttons for example). I don't need aspect ratios other than 1:1 (...

WPF XAML: How to automatically scale down children of a component in XAML?

Here's my problem: xaml file 1: a templated list control <ItemsControl ItemSource={Binding myUIrelatedDataList}/> <ItemsControl.ItemTemplate> <DataTemplate> <my:DynamicUIPresenter Width="160" Height="80"/> <!-- here, I want to specify my desired size to which i want to scale down the gene...

xClassNotDerivedFromElement error when adding Code Behind to Resource Dictionary in silverlight

I need to add code behind class to Resource Dictionary as described in this question. (I know that this is not a good practise but it should work based on the comments for linked question) .I'm referencing the code with x:Class attribute: XAML (separate Resource Dictionary file): <ResourceDictionary xmlns="http://schemas.microsoft....

Silverlight binding to an object contained in a list

I am trying with difficulty to use binding on an object which is contained in a list, so for example: Class A { IList<Class B> Items; } Class B { string name; } I want to have in xaml for example <Textblock Text="{Binding ClassA.Items[5].name}"/> So any ideas? much appreciated ...

WPF: How to get Radiobuttons to display as a horizontal row of ToggleButtons

Hi everyone! I'm currently building a UI that is going to be used in a touch panel. Therefore, I would like to display any RadioButton groups as horizontal rows of ToggleButtons. I already figured out how to display ToggleButtons instead of the standard bullet items: <Style x:Key="{x:Type RadioButton}" TargetType="{x:Ty...

WPF: Row of ToggleButtons with equal length?

Hi all, I'm currently displaying RadioButtons in my application as rows of ToggleButtons (see my last question). However, I'd like the buttons to be of the same width - currently, every button is just as wide as it has to be. Since I'm working with templates, I'd like to avoid specifying the width every time I use the control if poss...

WPF newbie - setting ItemsSource in XAML doesn't seem to work

I'm new to WPF and trying to figure out all this databinding stuff. When I do the following in my code, my ComboBox is populated when I run my application: public NewForm() { InitializeComponent(); Product.ItemsSource = Products; } public List<string> Products { get { return _productsComponents.Keys.ToList(); } } However...

Using XAML and Silverlight 4, is there a way to build up a dynamic GRID rows and columns from databinding?

I'm trying to have a regular grid rows and columns defined dynamically using databinding in XAML only. I know I can use code behind for this but I'm looking for a way to do it purely in XAML. Any thoughts? ...

WPF: Show new window using XAML

Is there a way to launch a new window in WPF using XAML? Or does it have to be done from code behind? ...