stackpanel

WPF ToolBar Separator shrinks to nothing when inside a StackPanel

孤街浪徒 提交于 2019-12-10 13:09:33
问题 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 Header="Test2" /> <StackPanel Orientation="Horizontal"> <Separator /> <MenuItem Header="Test3" /> <MenuItem Header="Test4" /> <MenuItem Header="Test5" /> </StackPanel> </ToolBar> </Grid> </Window> The Separator

Silverlight 4: StackPanel doesn't resize, when content gets more narrow

我们两清 提交于 2019-12-10 11:25:16
问题 I am using Silverlight 4 with Blend 4. I have a (horizontal) stackpanel that includes some TextBoxes and a Button. The stackpanel is set to stretch to the size that the content uses. The TextBoxes are on autosize too. When I add text to the Textboxes, the textbox size grows and the stackpanel grows too. So far so good. When I remove text from the textboxes, the textbox size shrinks (as excepted), but the stackpanel size doesn't. Is there any trick to make the stackpanel change size, when the

Change StackPanel location on a Canvas programmatically

时光总嘲笑我的痴心妄想 提交于 2019-12-10 10:43:07
问题 I have stackpanel in a canvas The stackpanel has <Canvas x:Name="MyCanvas"> <Slider Template="{StaticResource simpleSlider}" x:Name="seekBar" Thumb.DragStarted="seekBar_DragStarted" Thumb.DragCompleted="seekBar_DragCompleted" Canvas.Left="347" Canvas.Top="746" Width="900" Height="2" /> <Rectangle Height="5" /> <StackPanel Canvas.Left="200" Canvas.Right = "100"> </StackPanel> </Canvas> At runtime I need to change the location of the objects within the StackPanel. Ie seekBar.Canvas.Left = 50

How to hide/show items in a stack panel?

早过忘川 提交于 2019-12-10 10:19:47
问题 I have a wpf-mvvm application. In that I have follwoing... <Combo box> item 1 item 2 </Combo box> <stack pnel> <user control 1 /> <user control 1 /> </stack pnel> If user select "item 1" from combo, i need to display "user control 1" If user select "item 2" from combo, i need to display "user control 2" In the viewmodel...I have an IList of those two combobox items. what is the best way to hid/show items here ? 回答1: You can actually remove the StackPanel completely, as you'll only be showing

Defining DataTrigger for StackPanel

我们两清 提交于 2019-12-08 15:16:43
问题 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 following simple DataTrigger : <StackPanel x:Name="PersonPanel" DataContext="{Binding CurrentPerson}"> <TextBlock Text="{Binding Id}" /> <TextBlock Text="{Binding Name}" /

inter related stack panel sizing

谁说胖子不能爱 提交于 2019-12-08 07:19:17
问题 I have a recursively defined user control that needs the following properties: there are two columns the first contains a single border around some text the second column contains a stack of these same type of controls (the recursive part) if the box in the first column is shorter than the total height of the stacked boxes in the second column, the box should expand to make both columns the same height. If the total height of the second column is shorter than the box in the first column, then

How can I set a StackPanels margins individually?

巧了我就是萌 提交于 2019-12-08 06:23:46
问题 I can set the margin of a stackpanel in code-behind like this: StackPanel sp2 = new StackPanel(); sp2.Margin = new System.Windows.Thickness(5); But how can I set each individually , both of these don't work: PSEUDO-CODE: sp2.Margin = new System.Windows.Thickness("5 0 0 0"); sp2.Margin.Left = new System.Windows.Thickness(5); 回答1: You can also try this: sp2.Margin = new System.Windows.Thickness{ Left = 5 }; 回答2: Margin is of type Thickness which is a structure. The parsing of "5 0 0 0" is a

Text in StackPanel doesn't wrap (wp7)

半城伤御伤魂 提交于 2019-12-07 13:32:41
问题 I have problem with text wrapping. Without StackPanel this TextBlock works, but i need to put small picture before text. Also I don't have two columns for this (i need only one column for first three rows) <ListBox.ItemTemplate> <DataTemplate> <Grid> <Grid.RowDefinitions > <RowDefinition Height="60"/> <RowDefinition Height="170"/> <RowDefinition Height="50"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <TextBlock Grid.Row

How to add a ScrollBar to a StackPanel in Silverlight?

为君一笑 提交于 2019-12-07 07:48:01
问题 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 the entire page. Edit: My issue is more specificlly how I can get scrolling over a StackPanel . An example if the issue I am having is here: <Grid x:Name=

Using StackPanel as ContentControl (WPF)

北战南征 提交于 2019-12-07 05:07:59
问题 So I have a StackPanel that I am using as a ContentControl. I have a place where I want buttons to be generated based on data that I am binding to, and that is all working good, but I want the buttons to be laid out horizontally, not vertically as is what is currently happening. Here's a screenshot: And here is the code from my ContentTemplate description: <StackPanel Name="wpReleaseButtons" Orientation="Horizontal" Grid.Row="2"> <ItemsControl IsTabStop="False" ItemsSource="{Binding Path