xaml

WPF Change Grid.ColumnSpan on trigger

tl;dr: I want detail views to appear in 2 columns if 2 items are selected, and to span 2 columns if only 1 item is selected. I have a DockPanel with 2 ListBoxes docked on the left and a 2-column Grid on the right. When an item is selected in listBox1, I display a details view in Column 0 of the Grid. When an item is selected in lis...

Adding an image to a button in XAML

I'm trying to add an image to a button in my silverlight 3 application but cannot get the image to appear. I added a folder, named \images, to my Silverlight application folder and an using a relative path in the Source attribute of the Image. What am I doing wrong? <Button Width="200" Height="200"> <Image Source="images\do...

Visual Studio 2008 XAML Designer doesn't like default name space in same assembly.

Environment Visual Studio 2008 SP1 Visual C# WPF Application Project .NET Framework 3.5 Problem You have a user control in the same assembly as another user control or window, and you are using it in this new user control or window. It compiles and runs fine, however the designer doesn't work and gives an exception "Could not crea...

TextBox with automatic culture formatting?

I'm trying to create a TextBox that only allows positive integer input, and that should display the input with culture-specific formatting automatically (in this case en-US, so it should use the ',' sign as a separator for larger numbers). So: An entry of 1000 should show as '1,000' in the TextBox An entry of 1,000 should show as such,...

How to bind ScaleTransformation.X to slider in Silverlight 3

Hi, I need to zoom Canvas. In WPF it is possible to bind ScaleTransformation.X to slider.Value. I'm not able to do the same in Silverlight - some errors. Is it supported in SL3? Thank you. ...

WPF "Selected" Property of Custom Control or "Logical Focus". What should be used?

In my WPF project I have a custom control which is visually represented by a rectangle object. In XAML I put a number of rectangles based on this custom control. User should be able to select a group of these rectangles by mouse clicks and then do some actions with these selected rectangles. How I should implement the possibility of sel...

WPF: Can I put a colour animation in a style?

This is a simple WPF window in XAML: <Window x:Class="AnimateTest.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300" x:Name="MainWindow" Style="{StaticResource TestStyle}"> <Grid> </...

Where should be put XAML for layout of custom control in WPF?

After custom control is created there automatically appeared file for C# code - MyCustomControl.cs: public class MyCustomControl : ContentControl { static MyCustomControl( ) { ... DefaultStyleKeyProperty.OverrideMetadata(typeof(MyCustomControl), new FrameworkPropertyMetadata(typeof(MyCustomControl))); }...

UIelement position relative to Window

Hi In WPF, I want to get the corner location of a TabControl in my code, so I can set a ToolWindow's location accordingly when shown. How do I get the location of a given UIElement ? buildingInfoWindow = new BuildingInfoWindow(); // BuildingWindow : System.Windows.Window buildingInfoWindow.Owner = this; //buildingInfoWindow.Left = ?;...

How to define stroke around background rectangle of textblock in WPF?

I would like to have some text to be inside a rectangle with stroke around this rectangle (just like property "Stroke" of the object "Rectangle" itself). But I didn't manage to find a property of the object "Textblock" wich defines such a stroke. ...

How to set RichTextBox Font for the next text to be written?

Hi, I need to set the font family for the next text to be written in a RichTextBox. I tried setting that with... <RichTextBox x:Name="RichTextEditor" MaxWidth="1000" SpellCheck.IsEnabled="True" FontFamily="{Binding ElementName=TextFontComboBox, Path=SelectedItem}" FontSize="{Binding ElementName=TextSizeComboBox...

Binding of TextBlock inside Custom Control to dependency property of the same Custom Control

I have a custom control with a TextBlock inside it: <Style TargetType="{x:Type local:CustControl}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type local:CustControl}"> <Border Background="Blue" Height="26" Width="26...

How I should reference Custom Control in C# code behind file event trigger?

In Xaml page I reference my custom control this way: <MyNamespace:CustControl x:Name="Cust1" /> Now I want change the property of this custom control in MouseLeftButtonDown event trigger: private void Grid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { } But when I try to write something like CustControl.Is...

XAML grid column resizing when contents are scaled

Is it possible to automatically resize a grid column in XAML when its contents are scaled? Below are two screenshots to better explain what I mean. When the UserControl is first displayed it looks like: The intention is that the white rounded rectangle (with the textblock, combobox and slider) should always be positioned off to the ...

XAML Treeview, how to displayed nodes horizontally instead of vertically

I'm kinda new at XAML and I'm trying to figure how to display the TreeView nodes horizontally instead of vertically, i.e Header 1 Item 1 Item 2 item 3 Header 2 Item 4 Instead of Header 1 Item 1 Item 2 Item 3 Header 2 Item 4 It's not really as simple as it seems, I was able to get the headers to go horizontally thou...

WPF XAML Intellisense doesn't work correctly for custom routed event handlers

I defined a custom routed event with the following constructs (names changed): public class MyRoutedEventArgs : RoutedEventArgs {...} public delegate void MyRoutedEventHandler(Object sender, MyRoutedEventArgs args); public static readonly RoutedEvent MyEvent; MyClass.MyEvent = EventManager.RegisterRoutedEvent("MyE...

sql 2 xaml generator

Is there a more serious/commercial tool (than this) for generating a simple wpf forms from ms sql table metadata? ...

Wrapping a control in a border using styles without overwriting default appearance

What I'm attempting to do is wrap a control in a border without changing it's default appearance, and also without having to create custom controls. I'd like to do the equivalent of this: <Border BorderBrush="Red" BorderThickness="3"> <Button>Hello!</Button> </Border> Just to any control, without actually having to wrap everything ...

Application Navigation Framework (SL) with MVVM

Hi, how i can use Application Navigation Framework (SL) with MVVM, I'm use MVVM Light Toolkit.. Thanks. ...

What's the shorter xaml syntax for Multibinding using StringFormat with multiple bindings?

Hi for a single binding, we use: <TextBlock> <TextBlock.Text> <MultiBinding StringFormat="{}{0}"> <Binding Path=EmployeeName/> </MultiBinding> </TextBlock.Text> </TextBlock> or a shorter syntax: <TextBlock Text="{MultiBinding StringFormat=\{0\}, Bindings={Binding Path=EmployeeName}}"/> Now, if you have multibi...