xaml

Is there WPF XAML for Uniform fit but constant StrokeThickness

I what to draw a circle that uniformly fits into its space, with a constant a stoke thickness. A ViewBox gets me the uniform fit, but not the constant stoke thickness. <Viewbox Stretch="Uniform" MinHeight="10" MinWidth="10" > <Ellipse Height="10" Width="10" Fill="Red" StrokeThickness="1" Stroke="Yellow"/> </Viewbox> ...

What is the best XAML combination of elements for a standard Form?

I want to make standard database-table editing form in XAML: field labels on left input boxes on right (or dropdowns, radiobuttons, etc.) should be flexible for dynamic data so if the labels are long it either expands or wraps the text nicely My experience with XAML when I want to build something structured like this is I have to spe...

How can I define my own columns in a WPF DataGrid?

I've got a AutoGenerateColumns WPF-DataGrid getting bound in code-behind to LINQ-to-SQL, which works fine. But when I take off teh autogeneratecolumns and define my own columns, it tells me "The items collection must be empty before using ItemsSource." But I'm not binding the ItemSource in my XAML so I don't see why it isn't empty. Wha...

XAML Rectangle Property Trigger problem

I have a WPF app with a Rectangle trigger defined as: <Style TargetType="{x:Type Rectangle}"> <Setter Property="Rectangle.StrokeThickness" Value="1"/> <Style.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Rectangle.StrokeThickness" Value="4"/> </Trigger> </Style.Triggers> </Style>...

In WPF, how can I cancel the keypress after processing it with PreviewKeyDown?

In my WPF Datagrid I capture the "delete" key, process it, and then the datagrid itself deletes the row from the UI by continuing to process its own handler for the delete key (which is what I want). But now I want CTRL-S to open up a search bar, which it does, but it also goes on to blank out the cell the user was on when he pressed CT...

Array binding Xaml by Position (Silverlight) - on Datagrid

Hi, I have a list of string array as input. The array dimension are static for all the list but I can't know the array size until the list is retrieved. I need to bind the list in a datagrid in Silverlight. I tryied to create columns at runtime, binding each column to a particular array position but cannot find a way. Have you any ...

Setting WPF nested control properties from the parent control

I have a WPF window, with multiple ListBox controls on it, all sharing the same style that I've simplified here: <Style x:Key="listBox" TargetType="{x:Type ListBox}"> <Setter Property="ItemTemplate"> <Setter.Value> <DataTemplate> <Border BorderBrush="Black"> ...

Google code search - missed languages

This is very odd, but I don't see neither PowerShell nor XAML among supported languages http://www.google.com/codesearch/advanced_code_search ?! How can I filter results for that languages? ...

How can I apply a style to the Window Control in WPF?

I am setting a style for the Window in the App.xaml like such: <Application x:Class="MusicRepo_Importer.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:System="clr-namespace:System;assembly=mscorlib" StartupUri="TestMaster.xaml"> <Application.Resourc...

How to dynamically access element names in XAML?

I have a XAML input form which the user fills out. I want to validate this form. I have the field information in a collection which I want to loop through and check each field. But how do I access the name of the field when it is in a string, e.g. when fieldInformation.FieldName = "CompanyName" I want to check "Field_CompanyName.Text"...

How to use StringFormat in XAML elements?

I'm deep in a XAML stack of elements binding to orders. The order date displays as e.g. "12/31/2008 12:00:00 AM". I want it to display as e.g. "31.12.2008". How can I do this? I have seen other stackoverflow questions mention StringFormat but they use multibinding in ways that I can't get to work. Here is the kind of syntax I would l...

How to put XAML right-align code into a style?

It taking 5 lines to right-align a DataGridTextColumn is bloating my XAML. How can I put this "right-align code block" into a style and call it from an attribute, e.g. class="rightAlignDataGridTextColumn". <toolkit:DataGridTextColumn Header="Order Date" Width="Auto" Binding="{Binding OrderDate, StringFormat='{}{0:dd.MM.yyyy}'}" ...

How do I bind a Byte array to an Image in WPF with a value converter?

I'm trying to bind a Byte array from my databse to a WPF Image. My XAML: <Window.Resources> <local:BinaryImageConverter x:Key="imgConverter" /> </Window.Resources> ... <Image Source="{Binding Path=ImageData, Converter={StaticResource imgConverter}}" /> I've modified code published by Ryan Cromwell for a value converter: Class Bi...

Why won't this change the color of my WPF Datagrid headers?

I fill my datagrid in code behind like this: var customers = from c in _db.Customers select c; TheDataGrid.ItemsSource = customers.ToList(); In my XAML below, the DataGrid.RowBackground works but the DataGridHeaderBorder gets the error "The Items listing must be empty before the use of ItemsSource" in the code-behind u...

How to instantiate object in UserControl.Resources?

Hi, I am designing a listbox and I want to have design time data in it. If have a class in my namespace, how do I instantiate and object of that class in the Resources of the user control XAML please? Malcolm ...

Dynamically Change a Rotation Animation in WPF

I am using a DoubleAnimation to anamiate the Angle property of a RotationTransform. Several times per second, I need to change the rate of the rotation in response to external data so that the rotation speeds up and/or slows down (smoothly) over time. I am currently doing this by using a DoubleAnimation that repeats forever from 0.0 to 3...

Is it possible to set a style in XAML that selectively affects controls?

In <Window.Resources> I have defined following style: <Style x:Key="textBlockStyle" TargetType="TextBlock"> <Setter Property="Margin" Value="5,0,5,0"/> </Style> I have defined some grid where I have four TextBlocks: <WrapPanel> <TextBlock Style="{StaticResource textBlockStyle}">Server</TextBlock> <...

Showing Tooltip of WPF control under the decrative touches

I have a window with a number of controls upon it, each control with a Tooltip associated. In an effort to jazz up the window a little, I have overlayed some semi-transparent ellipses which gives the whole window a glossy finish, however, in some cases the positioning of these ellipses are preventing the hit-test getting down to my cont...

Selecting all items after binding wpf listview

I have the following XAML: <ListView x:Name="debitOrderItems" ItemsSource="{Binding DebitOrderItems}"> <ListView.ItemTemplate> <DataTemplate> <CheckBox x:Name="checkbox" Content="{Binding}" IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListViewItem}}, Path=IsSelected}" /> </DataTem...

Is there any tool to convert from XAML to C# (code behind)?

Hi! I am looking for an easy way to convert some XAML animation to C# code. Is there any tool available to do that? Thanks! Wally This is the code I am trying to convert: <Storyboard x:Key="Storyboard1"> <Rotation3DAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="DefaultGroup" Storyboard.TargetPrope...