xaml

C# function called after dependency property have been set

My code currently looks like this: private Foo myFoo; public Foo CurrentFoo { get { return myFoo; } set { SetFoo(value); } } private void SetFoo(Foo newFoo) { // Do stuff // Here be dragons myFoo = newFoo; } To be able to bind it in XAML/WPF I need to turn Foo into a dependency property: public static Dependenc...

How do I stop property values from flowing down the element tree in xaml?

Hi Let's say I have some Control that has been disabled. It contains a bunch of elements, but I want one of those child elements to remain enabled. Something like this: <ContentControl IsEnabled="False"> <Border> <Button Content="Button" IsEnabled="True"/> </Border> </ContentControl> So in this example, the Button's ...

Silverlight 4 XAML Collections

Hello, I have authored some custom classes that I would like to create using XAML: <Grid Width="300" Height="300"> <l:DashboardTable> <l:DashboardTable.DashboardTableQuery> <dq:DashboardTableQuery ConnectionString="Data Source=bunkerhill;Initial Catalog=emgov_data;User Id=emgovadmin;Password=p...

WPF Binding to change fill color of ellipse

Probably a simple question but: How do I programmatically change the color of an ellipse that is defined in XAML based on a variable? Everything I've read on binding is based on collections and lists -can't I set it simply (and literally) based on the value of a string variable? string color = "red" color = "#FF0000" ...

How to set focus to a brand new TextBox which was created as a result of a databinding in WPF?

Hi everyone, I have a WPF ItemsControl that is bound to an ObservableCollection. The XAML: <ItemsControl Name="mItemsControl"> <ItemsControl.ItemTemplate> <DataTemplate> <TextBox Text="{Binding Mode=OneWay}"></TextBox> </DataTemplate> </ItemsControl.ItemTemplate> </...

Calling two different animations from the same click event

Hi Stackoverflow, I'm currently working on a Surface application where I need to call two different animations when a button is tapped. How exactly should I be doing this? I'd like to do it declaratively if it's possible. Should I be using MultiTriggers for this, or? Thanks in advance! ...

How to start a ColorAnimation from a MultiTrigger in a ControlTemplate ?

Hi all I have the following ControlTemplate for a WPF TabItem: <ControlTemplate x:Key="DefaultTabItemTemplate" TargetType="{x:Type TabItem}"> <ControlTemplate.Resources> <SolidColorBrush x:Key="UnselectedForegroundBrush" Color="#414141" /> <!-- Unique color for this template --> <SolidColorBrush x:Key="Selec...

WPF - ListBox ignores Style When ItemsSource is bound

Hi, I have created styled a ListBox in WPF so that it is rendered as a checkbox list. When I populate the ListBox's items manually, the styling works perfectly. However, when I instead bind the ItemsSource of the ListBox to a static resource (an ItemsControl containing the required items), the styling is completely dropped. Here's the...

How do you reference another element in a xaml list

I'm using xaml as a datastore because It's quick and we haven't yet defined a file format. But I can only seem to create xaml that is a pure tree, even if it is acyclic. I know how to create a list of items in xaml, but How do I share objects in two lists? Below is an example of what I'm trying to say. <CreaturFile> <CreatureFile.M...

XAML: How do I append a percent symbol to a bound label value?

I have a label bound to the value of a slider. Content="{Binding Path=Value, ElementName=Slider}" How do I append a percentage symbol? The value of the slider is already formatted correctly, so when the value is '50', all I need is '50%'. Edit 0: I know how to do it in code behind but I was hoping to accomplish this in xaml without...

WPF Auto height in code

How could I set the value of the Height property of a WPF control in C# code to "Auto"? <Grid.RowDefinitions> <RowDefinition /> <RowDefinition Height="Auto" /> <RowDefinition /> <RowDefinition Height="Auto" /> <RowDefinition...

Silverlight 3 Application Background

I am new to Silverlight development. I have created a nice png file in Expression Design. I would like to use this png file as the background for my application. When I set the Stretch property to fill, it does not fill the entire page like I think it should. Here's the xaml: <Grid x:Name="LayoutRoot"> <Grid.Background> <ImageBru...

Difference between Popup's IsOpen and Visibility properties?

I've played around with the WPF Popup Control and as far as I can see, the Visibility property is superfluous. If you have a Popup with IsOpen = True, it will be visible even if its Visibility = Collapsed. If you have a Popup with IsOpen = False, then its Visibility will be Collapsed, and will remain "Collapsed" when IsOpen changes to ...

WPF - DataGrid Column Header Alignment

Hi all, I'm using the WPFToolkit DataGrid control and I wanted to restyle some of the column headers so that the header text is displayed vertically instead of horizontally (the data in the column is all numeric and therefore, not very wide, but the header text is long). So I created a DataTemplate to and tried to get the DataGridColumn...

WPF context menu bound to List<> dependency property

Im trying to make the contents of a List thats a dependency property show up in a WPF context menu. I have a class with the following dependency property, a list of Foo's (data holding class): public List<Foo> FooList { get { return (List<Foo>)GetValue(FooListProperty); } set { SetValue(FooListProperty, value); ...

WPF ListBox Data Binding Works in Designer but not Runtime

I have a maddening problem - I cannot get basic data binding to work even with copied examples. In the designer the listbox has 2 items but at runtime it's empty. <Window x:Class="BasicTables" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Basic...

Trying to get a better understanding of SelectedValuePath and IsSynchronizedWithCurrentItem

The following XAML produces a run-time Binding error when I click on an item in the ListBox: <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="WpfApplication1.MainWindow" x:Name="...

Why can't I set the Image Source in WPF app?

I'm just learning WPF. I'm using VS 2008. I've added an Image control to my XAML, and I added a GIF file to the project. If I use the XAML Designer's property panel to set the image's Source property, the drop-down list for the Source property contains the following: C:\Sample Project;component/pinHorizontal.gif There are several prob...

WPF Combobox textbox not updating when binding changes.

I have a WPF CombBox as follows: <ComboBox ItemsSource="{Binding Source={StaticResource myList}}" SelectedItem="{Binding Path=mySelectedItem}" /> The problem I have is that when the bound value changes, the selected value in the combobox's textbox does not update. (Note - the values in the combobox list do update). I am using ...

XAML itemscontrol visibility

Hello, I have a ItemsControl in my XAML code. When some trigger occur i want to collapse the full itemsControl, so all the elements. <ItemsControl Name="VideoViewControl" ItemsSource="{Binding Videos}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> ...