xaml

Declaring list and binding property values via XAML for a custom silverlight control

I feel like I've missed something obvious, but when creating a custom control in Silverlight I can declare properties as public and they will be exposed when making XAML declarations, so I can easily do something like this: public class MyControl : UserControl { public string Title {get; set;} } And this: <local:MyControl Title="...

WPF Animation Not Playing

I have the following xaml to show a rotating ellipse: <Ellipse x:Name="ellipse" Stroke="{StaticResource _SpinnerGradientBrush}" StrokeThickness="20" RenderTransformOrigin="0.5,0.5" > <Ellipse.RenderTransform> <TransformGroup> <RotateTransform Angle="0" /> ...

WPF ComboBox DropDown using PlacementTarget

I have a ContentControl comprised from left to right of a Button, partition and a ComboBox. I want the ComboBox dropdown to line up with the left side of the control as opposed to the left side of the combobox. I received a method in code but I was wondering whether if it could be accomplished in xaml. This gives me the name of the con...

How to trim whitespace from a data-bound XML element in WPF using XPath?

How can the whitespace at the start and end of the content of an XML element be removed when binding to the element using XPath in WPF? ...

How do I create a binding that involves some sort of formula?

As an example, if I have an element whose size I want to be twice the size of another element, how would I achieve this? An example would be the following, mirroredObject is the object that I want to use half of it's width for the width of the Border object. <Border Width="{Binding ActualWidth, ElementName=mirroredObject, Mode=Default}...

What strategy should be used for converting real world measurements to WPF units?

We have an application that will be reading real world dimensions from the DB in milimetres, these values will then be presented to the user in WPF. Currently I'm using the following strategy when reading objects from the data store by multiplying MilimetresPrWpfUnit in the following example. public const double MilimetresPerInch = 25.4...

Wpf, using a StaticResource SolidColorBrush to define the Gradient Stop Colors

I am creating some wpf resourceDictionaries whit all the styles for an application! I have a few LinearGradientBrush'es, where the color is set directly in the LinearGradientBrush reference as GradientStop's. However, I want to have a predefined set of colors that I can use a a reference for each GradientStop, so that changing the color ...

DataTrigger / Style quick in XAML

Hey I have an Ellipse defined as so <Ellipse Stroke="#FF474747" Style="{StaticResource SelectedTemplate}" Fill="{StaticResource RedGradient}" /> I also have two styles setup like so <RadialGradientBrush x:Key="RedGradient" GradientOrigin="1,1"> <GradientStop Color="White"/> <GradientStop Color="Red" Offset="1"/> </RadialGrad...

Embed multiple icons in WPF EXE

I have a WPF assembly in which I would like to embed five icons for different filetypes associated with my application. How can I embed these icons into my EXE? @smoore @Groky @ChrisF, thank you. Unfortunately, this is not what I asked. I see that my question was quite vague 0_­°. Let me rephrase the question: I have icons, say App...

XAML:The attachable property VisualStateGroups was not found in type VisualStateManager

I'm using VS2008 EE SP1 + WPF + XAML. In the beginning I added a reference to it: xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows" I'm getting this error while compilation: <vsm:VisualStateManager.VisualStateGroups> <vsm:VisualStateGroup x:Name="CommonStates"> <vsm:VisualStateGroup.Transi...

Map complex UI to Object cleanly and efficiently.

I currently have an app (in Silverlight), using mv-vm, that has an interface to add/edit/remove various entries to a database. A good analogy would be a page for ordering a car with many checkboxes and comboboxes for whatever features you wanted the car to include. My app has many of these UI elements (even including TreeViews with Tree...

How do I select an item in my WPF ComboBox based on my data binding?

I've got my DataContext set to a Book object. Book has properties: Title, Category. I've got a CollectionViewSource "categoryList" that holds a list of Categories. Question: How do I select the book's Category in this combobox? <TextBox Text="{Binding Path=Title}"/> <ComboBox SelectedValuePath="Id" SelectedValue="{Binding...

Align / scoll issues in XAML Listbox

Apologies for the ambiguous title. I want the items of my listbox to display similar to a photo gallery - imagine Thumbnail view on Windows File Explorer. I have a listbox defined as so <ListBox ItemsSource="{Binding RUFView}" x:Name="RUFs" Margin="228,34,12,12" Background="Transparent" BorderBrush="#007F9DB9"> <ListBox.ItemsPanel...

wpf textblock autosize/layout in stackpanel

I have the following stack panel <StackPanel> <TextBlock Text="{Binding AddressLine1}" /> <TextBlock Text="{Binding AddressLine2}" /> <TextBlock Text="{Binding AddressLine3}" /> <TextBlock Text="{Binding AddressLine4}" /> </StackPanel> and my AddressLine2 string is null on the bound object. My stack pane...

How can I get my ScrollViewer to scroll the view area?

I have a Grid inside a ScrollViewer inside a Border inside a StackPanel inside a Window. The ScrollViewer puts a scrollbar on the right, but it is not scrollable. How can I get the ScrollViewer to make its contents scrollable? <Window x:Class="TestScroll234343.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presenta...

How can I get images in XAML to display as their actual size?

I have a 27 x 27 pixel image that I am displaying in WPF but it displays larger than the size of the window. How can I get it to display its actual size? XAML: <Window x:Class="TestImage23434.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" ...

XAML without the .xaml.cs code behind files.

I'm using WPF with the Model-View-ViewModel pattern. Thus, my code behind files (.xaml.cs) are all empty, except for the constructor with a call to InitializeComponent. Thus, for every .xaml file I have a matching, useless, .xaml.cs file. I swear I read somewhere that if the code behind file is empty except for the constructor, there ...

How can I make a hover info bubble appear on mouseover in WPF?

I want to make bubble of text appear when the mouse is over a TextBlock. The following code is the closest I can get but it just injects text into TextBox.Text itself and changes the color. I want to have a e.g. Border/StackPanel/TextBlock above the original textblock floating on a different layer during mouseover. How can I make a hov...

How can I make a WPF ToolTip appear faster with ToolTipService.Duration?

How can I make the Tooltip in the following code display faster? using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; namespace TestHover29282 { public partial class Window1 : Window { public Window1() { InitializeComponent(); TextB...

Bind FontWeight to a Boolean in Silverlight

Silverlight does not feature DataTriggers, so in this case... what might be the best way to conditionally set the fontweight of an item to a boolean? For example... the following is not possible in Silverlight. <TextBlock Text="{Binding Text}"> <TextBlock.Triggers> <DataTrigger Binding="{Binding IsDefault}" Value="True"> ...