xaml

What is the good way to represent a list of choices for a combo box or list box in XAML?

Anything is more compact (or otherwise better) than <x:Array x:Key="titles" Type="System:String"> <System:String>Mr.</System:String> <System:String>Mrs.</System:String> <System:String>Ms.</System:String> </x:Array> ? ...

How to set a Code-based rectangle's style from a XAML resource file by code.

I created a resource file as 'Style' which sets the fillcolor and border of a rectangle. In 'code' I create a rectangle which is dynamic in size as it's being set by another rectangle size. What I want is to create the code-based rectangle and have its style set by the resource xaml-file. How can I do this other then to set it by code....

In Silverlight 3.0, can I create a data template in an external file that includes a reference to an event handler?

Is it possible to include an event handler reference in a data template that is not associated with the code-behind where the event handler is defined? I'm getting a PARSER-BAD-PROPERTY-VALUE when trying to pull this off. For example, let's say I have this very simple XAML. page.xaml <DataTemplate x:Key="ItemsTemplate"> <Hyperli...

WPF: How do I inherit property values to all child controls?

I have UserControls containing other controls. I want that if I set a Foreground color for the UserControl, all child controls automatically inherit it. I have the same problem with font style/size. Can I set these properties somehow to auto/inherit? Is this possible to set all subcontrols without a loop? ...

Wpf ImageButtons?

Hello! I created a WPF application that has many buttons. Now the customer wants to change all the buttons to icons. For example: All the OK buttons should have the same icon, all the cancel btns and so on. I want to put in all the buttons Style="{StaticResource ButtonStyle_OK}", Style="{StaticResource ButtonStyle_OK}" etc. Now my qu...

How do you insert a binding into the middle of a sentence of a TextBlock in WPF?

I'm looking for something along these lines: <TextBlock Grid.Column="1" Text="Welcome, {Binding UserName}!" /> This will of course actually display the text "{Binding UserName}" to the user rather than decode it, but I know you can do something like this with ASP.NET, so I'm hoping there's a way to get this to work in WPF. I'...

How to have Width and Height reflect ScaleTransform and how to ScaleTransform by setting Height and Width?

I have an issue with regards to using a ScaleTransform on a Canvas in Silverlight, the Canvas scales correctly, however the Height and Width values always remain the same. e.g. a 100x100 Canvas scaled so it appears 200x200 is still 100x100 with regards to the Height and Width values, how can these be updated to reflect the new size. A...

In a WPF combobox is it wise to use a string type value as the SelectedValue and SelectedValuePath?

Following on from my other post about primary keys I am wondering if there is a performance impact in using a string value as the key in WPF comboboxes. For example <ComboBox x:Name="TestCB" ItemsSource="{Binding Path=Products}" DisplayMemberPath="ProductName" SelectedValuePath="ShortCode" SelectedValue="{Binding Pat...

WPF CAD-like system - all data in classes

Still picking my way through learning XAML/WPF. If someone can show me how to accomplish the following - it will go a long way to helping me develop my next project (and several similar projects down the road). Say I have a collection of objects that defines objects to be drawn on a canvas. The objects contain all the information neces...

Custom Control and localization in Silverlight

I have a template called template1.xaml and when I call this in Page.xaml and bind a string to the custom control property called "Title" it works. for example: <Local:template1 Title="My Title" /> works in Page.xaml, but if I want to use Resx binding like this: <Local:template1 Title="{Binding Strings.Hello, Source={StaticResource S...

How do I create a Style within a WPF UserControl?

I want to set the style of some controls on my UserControl, but can't seem to find the right syntax: <UserControl x:Class="HiideSRM.WIDSModule.BiometricStatusIndicator" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" ...

How can I reference an attached property as the source of a data binding?

Here's a much-abbreviated sample of my code. <Grid> <Polygon Name="ply" Grid.Column="2" Grid.Row="0" Grid.RowSpan="3" Fill="Orange" Stroke="Orange" Points="0,1 1,3 2,2 2,0 0,0" /> <Line Grid.Column= "{Binding ElementName=ply, Path=Grid.Column, Mode=OneWay}" Grid.Row= "{Binding ElementName=ply, Path=Grid.Row, Mode=On...

Where to download XAMLPad?

If anyone know where to download XAMLPad? Or you know better alternative to test WPF? Thanks ...

WPF data-binding with multiple dependencies?

I believe this code may require more effort to comprehend than average, so I'm using contextual code-comments to explain my predicament in an effort to make it a little easier to understand my question. public class MyControl : System.Windows.FrameworkElement { public double Property1 { get; set; } public double Property2 { ge...

Why does Blend add [d:LayoutOverrides="Height"] and should I care?

Quite often when coming back to Visual Studio from Expression Blend 3, I see that Blend has helpfully added a "d:LayoutOverrides" property to my XAML. Growing up with ASP.NET designers, I naturally distrust anything I wouldn't type myself, so remove them as soon as I see them. I know that "d:" properties are designer-only and don't imp...

How do you format XAML in Expression Blend?

Does anyone know how to "format xaml" in Expression Blend similar to the option "Format Document" in Visual Studio? ...

How can I draw a "soft" line in WPF (presumably using a LinearGradientBrush)?

I'm trying to draw a line with soft edges, regardless of the slope. Here's the code I have so far: <Line HorizontalAlignment="Stretch" VerticalAlignment="Center" Stretch="Uniform" StrokeThickness="5" X1="0" Y1="0" X2="1" Y2="0"> <Shape.Stroke> <LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> <...

Access a named TextBox in the code behind from a ContentPresenter's DataTemplate

I am trying to get access to a textbox (textBoxAnswer) in the code behind of my WPF Page. The trouble is, because it is part of a DataTemplate, it is not auto-generated as a private member of the class, like it would be if I wasn't using the ContentPresenter + DataTemplate. (I am using the DataTemplate because I need to use DataTriggers,...

Problem with EventTrigger for MouseUp, it triggers only on right-button

Please take a look at the following snippet: <EventTrigger RoutedEvent="Image.MouseUp"> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetName="TranslateTransform" Storyboard.TargetProperty="X" From="1" To="0" Duration="0:0:0.15" /> <DoubleAni...

How to bind a property of an ItemsPanel to a property of the parent

Hello everybody, I have a custom panel that has a public dependency property MaxItemsCount(defines the maximum number of elements in the panel), and I am giving this panel as an ItemsPanel to my custom control. <Setter Property="ItemsPanel"> <Setter.Value> <ItemsPanelTemplate> <myPrimitives:MyPanel MaxItemsCount="5"/> ...