xaml

WPF ToolBar Separator shrinks to nothing when inside a StackPanel

Given the very simple wpf app <Window x:Class="Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="800"> <Grid> <ToolBar Height="50" > <MenuItem Header="Test1" /> <MenuItem Hea...

Indirect binding to child collections in XAML

Hi folks, I am currently using a Linq template with SubSonic3 to create my models. I have a simple Member class, which has a collection of Notes. A Note class has a PublishedDate and Title properties. I have a UserControl which has a collection of Members for its DataContext. There are two ListBoxes and a bunch of TextBoxes and other c...

Wrapping parallel ItemsControls?

I have 2 ItemsControls parallel to each other. The first is a set of TextBlocks with Property names and the second is a set of TextBoxes with Property values. Property1 Value1 Property2 Value2 Property3 Value3 " " The list goes on very long in some cases. Is there a way to possibly break the columns at a certain poin...

Creating a drop shadow style in XAML

I’m struggling a little bit with some XAML syntax I hope someone can advise on. I want to create an “Effect” type style resource which contains a DropShadowEffect definition which can be reused rather than always manually setting the properties. Here’s what I have: <Style TargetType="DropShadowEffect" x:Name="DropShadowEffectStyle"> <...

WPF Images don't display when View is switched out

I have the following WPF application <Window x:Class="Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:WpfApplication1" Title="Window1" Height="300" Width="300"> <Grid> <TabControl> ...

How do you set the FrameworkElement.Width property to the value of a qualifiedDouble, in the code-behind?

I'm trying to set the width property of one of my controls to a qualifiedDouble, as described here on MSDN. (Scroll down to the "XAML Values" section to see MSDN's info on the use of a qualifiedDouble) However, I want to know how to achieve this in the code-behind, rather than XAML. The UserControls I am creating do not have XAML atta...

Help with LINQ to update an XDocument

Hello, I have some xml: <Response TaskId="2429"> <message>Run for cover.</message> <element location="proj\survival.cs"/> <element location="proj\run.cs"/> </Response> I would like to add an attribute to each item: <element location="proj\run.cs" status="running"/> Is that possible with LINQ in C#? Thanks any tips... ...

How can I sort a ListBox using pure xaml and no code behind?

I need to sort the strings in a ListBox, but it is bound to the view model by another component via the DataContext. So I can't directly instantiate the view model in xaml, as in this example, which uses the ObjectDataProvider: http://www.galasoft.ch/mydotnet/articles/article-2007081301.aspx in my xaml: <ListBox ItemsSource="{Binding ...

Binding to a RoutedUICommand that's not in the codebehind.

I have a static class which contains a RoutedUICommand that I would like to use in binding. public static class CommandLibrary { public static ProjectViewModel Project { get; set; } public static RoutedUICommand AddPage { get; private set; } static CommandLibrary() { AddPage = new RoutedUICommand("AddPage", "Ad...

Binding ComboBoxes to enums... in Silverlight!

So, the web, and StackOverflow, have plenty of nice answers for how to bind a combobox to an enum property in WPF. But Silverlight is missing all of the features that make this possible :(. For example: You can't use a generic EnumDisplayer-style IValueConverter that accepts a type parameter, since Silverlight doesn't support x:Type. Y...

Dynamic Scoped Resources in WPF/XAML?

I have 2 Xaml files, one containing a DataTemplate which has a resource definition for an Image brush, and the other containing a content control which presents this DataTemplate. The data template is bound to a view model class. Everything seems to work EXCEPT the ImageBrush resource, which just shows up white... Any ideas? File 1: D...

ScrollViewer not scrolling....

The scrollviewer below does not work. I tried everything I could find on this site and beyond: embedding the scrollviewer in an Grid, embedding the ScrollViewer's children in a grid, embedding the Scrollviewer in a StackPanel with fixed height, setting/binding the height of the scrollviewer, all to no avail... Who shows me the way back t...

Acessing Storyboards from another XAMLS

Hello. I'm trying to build a Silverlight application where I use 5 XAMLS. The first one, "Page.xaml" contains a menu with 4 buttons and a Canvas to receive the each content XAML. Each Content XAML has 2 storyboards: "entrada" (the "enter section" animation) and "saida" (the section ending animation). I am experiencing the following pro...

AccessText inside Label (XAML to C#)

Hi, The following code is part of a small XAML application that displays data in a tabular form. Basically I need to translate this code into C#. <Grid Width="768" Height="1056"> <Grid.RowDefinitions> <RowDefinition Height="114" /> <RowDefinition Height="906*" /> <RowDefinition Height="36" /> </Grid.RowD...

Place a dividing line in a menu in WPF

In XAML, how do I put a standard dividing line in a menu? eg <MenuItem Header="_File" Name="m_fileMenu"> <MenuItem Header="_Open" Command="ApplicationCommands.Open"/> <!-- Trying to put a divider here! --> <MenuItem Header="-" /> <!-- Wrong guess --> <MenuItem ...

Bind the content of DataTemplate to another userControl

Hi all, may you happy every day I am new in silverlight Suppose I am writing a user control(name as AAA.xaml) which contains a DataTemplate, in which I want to have another user control's(defined in BBB.xaml) instance by data binding. I initilize a instance of BBB user control(name as bbb) in AAA.cs(the c# file of AAA.xaml), and I wan...

Putting ListBox in ScrollViewer: mouse wheel does not work

Hi all, My mouse wheel does not work when putting a ListBox in a ScrollViewer. Does the ListBox somehow "steal" this event? <ScrollViewer VerticalScrollBarVisibility="Auto" Style="{StaticResource myStyle}"> <ListBox> <ListBoxItem>Test 1</ListBoxItem> <ListBoxItem>Test 2</ListBoxItem> <ListBoxItem>Test 3</ListBoxItem> <ListBoxIt...

WPF - Making an animation's execution conditional on a property of the bound data item

I have a data object -- a custom class called Notification -- that exposes a IsCritical property. The idea being that if a notification will expire, it has a period of validity and the user's attention should be drawn towards it. Imagine a scenario with this test data: _source = new[] { new Notification { Text = "Just thought you ...

Naming Usercontrols. Convention?

So you've got a usercontrol. You would like to bind to some of its dependency properties, so you need specify an x:Name in order to use it. You can't do this... <UserControl x:Class="WpfApplication1.UserControl1" x:Name="UserControl1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="h...

XAML ImageBrush using a BitmapImage without a URI

I have the following XAML that displays a cover image for a book using a URI: <Rectangle.Fill> <ImageBrush ImageSource="{Binding CoverUrl}" /> </Rectangle.Fill> However, the image I would like to use is not on disk anywhere or accessible via a URI; it comes from inside a binary file that I parse out into a BitmapImage object. Whe...