stackpanel

How can I vertically align a TextBox inside a StackPanel?

In the following XAML, the word "Test" centers horizontally but not vertically. How can I get it to center vertically? <Window x:Class="TestVerticalAlign2343.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" WindowStartupLocation="CenterSc...

WPF - How to get only one expander expanded at any one time

I've got a StackPanel with a group of expanders in, how do I set it so that only expander is expanded at any one time? Cheers AW ...

How to expand a Slider to fill the available space when the slider is within a StackPanel

Inserting a Slider in a Grid would expand it to fill the available space, but I would prefer not use a grid for the following reason: I've a TextBlock and a Slider in a UserControl, the slider is spring loaded and does jog / shuttle; the current value has to be displayed because the user can't rely on the neutral cursor's position, so t...

How can I make elements arranged in a horizontal StackPanel share a common baseline for their text content?

Here's a trivial example of the problem I'm having: <StackPanel Orientation="Horizontal"> <Label>Foo</Label> <TextBox>Bar</TextBox> <ComboBox> <TextBlock>Baz</TextBlock> <TextBlock>Bat</TextBlock> </ComboBox> <TextBlock>Plugh</TextBlock> <TextBlock VerticalAlignment="Bottom">XYZZY</TextBlock> </St...

Align items in a stack panel?

I was wondering if I can have 2 controls in a horizontal-oriented StackPanel so that the right item should be docked to the right side of the StackPanel. I tried the following but it didn't work: <StackPanel Orientation="Horizontal"> <TextBlock>Left</TextBlock> <Button Width="30" HorizontalAlignment="Right">Right<Button> </Stac...

(VB.NET + WPF) Drag + Drop (to allow user sorting) of stackpanel elements within a Scrollviewer?

I have good model (I think!) for how to allow a user to drag an element in a stackpanel and reposition it to another location within the stackpanel. However, my Stackpanel is placed within a ScrollViewer, like this (generalized): <ScrollViewer> <StackPanel> ....First item ....Second item ....Third item ...

Does resizing a control in WPF resize its StackPanel?

I have a Canvas inside of a StackPanel in my WPF Designer in Visual Studio 2008. At runtime I plan to resize the Canvas so its client rect is a certain size (borders and other parts are just added onto that size). When I resize the Canvas, will the Width/Height of the StackPanel adjust itself accordingly? This is important since I have o...

Defining DataTrigger for StackPanel

How do I define a DataTrigger for a StackPanel? It does have a Trigger property, but defining a trigger here gives the following error on Initialize when starting the application: Failed object initialization (ISupportInitialize.EndInit). Triggers collection members must be of type EventTrigger. .... This is given from the follo...

How can I add a FlowDocument to a StackPanel?

I created the following class in order to have an easy way to display formatted text in a WPF document. However this solution returns a FlowDocument, and I am having trouble integrating this FlowDocument in my current application in which I was simply adding TextBlocks to StackPanels and WrapPanels and Borders, etc. How can I add the ...

Stackpanel add item animation

Hello, I've been struggling a while with marquee-style image scrolling control. At a moment, I stuck up with templated ItemsControl: <Window.Resources> <DataTemplate x:Key="itemsTemplate"> <Image Source="{Binding AbsolutePath}"></Image> </DataTemplate> </Window.Resources> <ItemsControl ItemTemplate="{StaticResource item...

Is there a better way than a grid to line up controls in WPF?

I am using a grid by the definition of appropriateness defined in this question Grid vs Stackpanel. However when working with grids you have to define the controls position inside them explicitly in the grid. This becomes a pain when having to reorder controls or when adding a new control to the grid. With the code provided as an example...

sorting elements in a stackpanel WPF

I have a stackpanel with some usercontrols that are added or removed during runtime. These elements have an index that i assign to them when i new them, I need to keep these elements sorted by that index so i wote a quicksort function that sorts them based on the index but on the line that does the swapping y = items[i]; //y ...

I need to rollup an expander AND the stackpanel object it sits on in the window

Here is the code I have and wondered how I could completely rollup the stack, expander and objects within it to push all objects below it to take up the space left after rolling up the upper stack and objects. My current code is below: <Grid> <StackPanel Margin="8,8,0,0" VerticalAlignment="Top" Height="225"> <Expander Header="Expand...

Populate StackPanel with checkbox's from Database

I am quite new to WPF. I have a page that displays data from a SQL database using L2S. The L2S returns a DataTable that contains all the available options to choose from for a specific area. Every row it returns from the DataBase needs to be a checkbox and I want to put those checkboxes in a stackpanel. Am I looking at databinding to...

WPF: Why all the love for the Grid control?

Seen various examples of WPF applications I've seen the use of the Grid control for almost anything, even simplest things with only 1 column or row. Also, the WPF templates start with an empty grid. For me, using StackPanel or DockPanel is less verbose and are better for maintenance (think adding a row later and having to add +1 to all...

WPF StackPanel spacing problem

My stackpanels have gaps between each item (TextBlocks). You can see through to whatever is behind on the background Canvas. I don't want gaps. I tried setting the margin of both the stackpanel and textblocks to zero. Didn't fix it. Creating the same thing in Blend shows no gaps (AFAIK). Here you can see the object behind mouse/moose s...

creating a design in wpf using stackpanel and reusing it?

I want to create a design using Stackpanel in XAML pad in WPF and then embed images on it using .cx file. But I am getting some error using Styles. <Style x:Key="TopPanelDesign" TargetType="{x:Type StackPanel}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type StackPan...

I can't set a border around my StackPanel. Any help?

Here's my XAML code: <Window x:Class="CarFinder.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Search for cars in TuMomo" Height="480" Width="600"> <DockPanel Margin="8"> <Border CornerRadius="6" ...

Silverlight: Scrolling with a StackPanel

I have a grid, 3 by 3 (3 rowdefinitions and 3 columndefinitions). I want some content (a StackPanel) in one of those grid cells to scroll. I'm fairly sure this is possible but I cannot figure out how. I've tried adding ScrollViewers and Scrollbar controls to the grid cell I want to scroll, but this usually ends up creating scrolling for ...

Is there a way to change the draw order in WPF

Is there a way to change the draw order of Controls in a StackPanel without changing the actual ordering of these controls in the StackPanel? The reason I ask is that we have a button bar with margin 0 between the buttons. The active button grows (ie margin set to -10) overlapping the neighbouring buttons. The problem here is that the r...