i used a GroupBox with a scrollviewer inside it ..and inside scrollviewer i put a grid and begin to put my controls (3 textblocks and 7 textboxes)
i can't make scrollviewer to scroll my content ..and i don't know if i miss something to activate it
here is my xaml code:
<GroupBox BorderBrush="#FF0000DD" FontSize="13" FontWeight="Bold" Header="General Information" HorizontalAlignment="Stretch" Margin="363,20,38,486" Name="groupBox1" VerticalAlignment="Stretch" Panel.ZIndex="0">
<ScrollViewer Height="Auto" Name="scrollViewer1" Width="Auto" ScrollChanged="scrollViewer1_ScrollChanged" VerticalScrollBarVisibility="Auto" >
<Grid Name="grid1" Height="132">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="1" Grid.RowSpan="1" Height="Auto" HorizontalAlignment="Right" Margin="0" Name="textBlock1" Text="Generic ID" VerticalAlignment="Center" FontSize="14" Padding="0" />
<TextBlock FontSize="14" Height="Auto" HorizontalAlignment="Right" Margin="0" Name="textBlock2" Text="Generic Name" VerticalAlignment="Center" Grid.Column="1" Grid.Row="1" Padding="0" />
<TextBlock FontSize="14" Height="Auto" HorizontalAlignment="Right" Margin="0" Name="textBlock3" Text="Other Names" VerticalAlignment="Center" Grid.Column="1" Grid.Row="2" Padding="0" />
<TextBox Height="23" HorizontalAlignment="Center" Margin="0" Name="textBox1" VerticalAlignment="Center" Width="197" Padding="0" />
<TextBox Height="23" HorizontalAlignment="Center" Margin="0" Name="textBox2" VerticalAlignment="Center" Width="197" Grid.Row="1" Padding="0" />
<TextBox Height="23" HorizontalAlignment="Center" Margin="0" Name="textBox3" VerticalAlignment="Center" Width="197" Grid.Row="2" Padding="0" />
<TextBox Height="23" HorizontalAlignment="Center" Margin="0" Name="textBox4" VerticalAlignment="Center" Width="197" Grid.Row="3" Padding="0" />
<TextBox Height="23" HorizontalAlignment="Center" Margin="0" Name="textBox5" VerticalAlignment="Center" Width="197" Grid.Row="4" Padding="0" />
<TextBox Height="23" HorizontalAlignment="Center" Margin="0" Name="textBox6" VerticalAlignment="Center" Width="197" Grid.Row="5" Padding="0" />
</Grid>
</ScrollViewer>
</GroupBox>
Try setting your GroupBox's Height. It is stretching to fill the entire Window and your content is stretching to Fit. If you limit the size of the GroupBox you will get your VerticalScroll and it will work. I modified your code to this and it works:
<GroupBox BorderBrush="#FF0000DD" FontSize="13" FontWeight="Bold" Header="General Information" HorizontalAlignment="Stretch" Height="132" Name="groupBox1" Panel.ZIndex="0">
<ScrollViewer Height="Auto" Name="scrollViewer1" Width="Auto" ScrollChanged="scrollViewer1_ScrollChanged" VerticalScrollBarVisibility="Auto" >
<Grid Name="grid1" Height="132">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="1" Grid.RowSpan="1" Height="Auto" HorizontalAlignment="Right" Margin="0" Name="textBlock1" Text="Generic ID" VerticalAlignment="Center" FontSize="14" Padding="0" />
<TextBlock FontSize="14" Height="Auto" HorizontalAlignment="Right" Margin="0" Name="textBlock2" Text="Generic Name" VerticalAlignment="Center" Grid.Column="1" Grid.Row="1" Padding="0" />
<TextBlock FontSize="14" Height="Auto" HorizontalAlignment="Right" Margin="0" Name="textBlock3" Text="Other Names" VerticalAlignment="Center" Grid.Column="1" Grid.Row="2" Padding="0" />
<TextBox Height="23" HorizontalAlignment="Center" Margin="0" Name="textBox1" VerticalAlignment="Center" Width="197" Padding="0" />
<TextBox Height="23" HorizontalAlignment="Center" Margin="0" Name="textBox2" VerticalAlignment="Center" Width="197" Grid.Row="1" Padding="0" />
<TextBox Height="23" HorizontalAlignment="Center" Margin="0" Name="textBox3" VerticalAlignment="Center" Width="197" Grid.Row="2" Padding="0" />
<TextBox Height="23" HorizontalAlignment="Center" Margin="0" Name="textBox4" VerticalAlignment="Center" Width="197" Grid.Row="3" Padding="0" />
<TextBox Height="23" HorizontalAlignment="Center" Margin="0" Name="textBox5" VerticalAlignment="Center" Width="197" Grid.Row="4" Padding="0" />
<TextBox Height="23" HorizontalAlignment="Center" Margin="0" Name="textBox6" VerticalAlignment="Center" Width="197" Grid.Row="5" Padding="0" />
</Grid>
</ScrollViewer>
</GroupBox>
With the result of this:
I modified your code a bit
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<GroupBox BorderBrush="#FF0000DD" FontSize="13" FontWeight="Bold" Header="General Information" HorizontalAlignment="Stretch" Margin="1,0,0,129" Name="groupBox1" VerticalAlignment="Stretch" Grid.Column="1" Grid.RowSpan="3">
<ScrollViewer Name="scrollViewer1" Width="Auto" VerticalScrollBarVisibility="Visible" >
<Grid Name="grid1" Width="376" Height="280">
<TextBlock FontFamily="Times New Roman" FontSize="14" FontWeight="Bold" Height="Auto" Name="textBlock4" Padding="0" Text="Generic ID" TextAlignment="Right" Margin="-20,0,20,0" />
<TextBlock FontFamily="Times New Roman" FontSize="14" FontWeight="Bold" Height="Auto" Name="textBlock5" Padding="0" Text="Generic Name" TextAlignment="Right" Margin="-10,20,10,-20" />
<TextBlock FontFamily="Times New Roman" FontSize="14" FontWeight="Bold" Height="Auto" Name="textBlock6" Padding="0" Text="Other Names" TextAlignment="Right" Margin="-15,43,15,-43" />
<TextBox Height="25" Name="textBox8" Width="225" Margin="22,199,130,44" />
<TextBox Height="25" Name="textBox9" Width="225" Margin="20,147,131,95" />
<TextBox Height="25" Name="textBox11" Width="225" Margin="20,97,131,159" />
<TextBox Height="25" Name="textBox12" Margin="21,122,131,121" />
<TextBox Height="25" Name="textBox13" Width="225" Margin="20,159,131,52" />
<TextBox Height="25" Name="textBox14" Width="225" Margin="20,222,131,20" />
</Grid>
</ScrollViewer>
</GroupBox>
</Grid>
Just try whether this works out.I think the margin and height are resulting in the problem
Related
I want to bind a button command from a listbox item. But my code not work. Can you help me?
My item template definition:
<UserControl.Resources>
<DataTemplate x:Key="MemberList">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="20"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
</Grid.RowDefinitions>
<Image Grid.Column="0" Grid.Row="0" Grid.RowSpan="2" Source="{DynamicResource appbar_user}" Height="30" Width="30" VerticalAlignment="Center" HorizontalAlignment="Left"/
<TextBlock Grid.Column="1" Grid.Row="0" Text="{Binding Name}" VerticalAlignment="Center" HorizontalAlignment="Left"/>
<TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding EMail}" VerticalAlignment="Center" HorizontalAlignment="Left"/>
<Button Grid.Column="2" Grid.Row="0" Grid.RowSpan="2" Width="25" Height="25" VerticalAlignment="Center" IsDefault="False" Content="X">
</Button>
</Grid>
</DataTemplate>
</UserControl.Resources>
And my listbox declaration:
<ListBox Margin="0,0,10,0" Grid.Column="0" Grid.Row="2" x:Name="_ownersList" ItemsSource="{Binding GroupOwners}" ItemTemplate="{DynamicResource MemberList}" >
<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}">
<EventSetter Event="Button.Click" Handler="Button_Click"/>
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
Thank you for your help.
It worked fine for me
XAML:
<Window.Resources>
<DataTemplate x:Key="MemberList">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="20"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
</Grid.RowDefinitions>
<Image Grid.Column="0" Grid.Row="0" Grid.RowSpan="2" Source="{DynamicResource appbar_user}" Height="30" Width="30" VerticalAlignment="Center" HorizontalAlignment="Left"/>
<TextBlock Grid.Column="1" Grid.Row="0" Text="{Binding Name}" VerticalAlignment="Center" HorizontalAlignment="Left"/>
<TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding EMail}" VerticalAlignment="Center" HorizontalAlignment="Left"/>
<Button Grid.Column="2" Command="{Binding DataContext.CloseButton,RelativeSource={RelativeSource AncestorType=Window, AncestorLevel=1}}" Grid.Row="0" Grid.RowSpan="2" Width="25" Height="25" VerticalAlignment="Center" IsDefault="False" Content="X">
</Button>
</Grid>
</DataTemplate>
</Window.Resources>
<Grid Height="200" Width="200" VerticalAlignment="Center">
<ListBox Margin="0,0,10,0" Grid.Column="0" Grid.Row="2" x:Name="_ownersList" ItemsSource="{Binding GroupOwners}" ItemTemplate="{DynamicResource MemberList}" >
<!--<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}">
<EventSetter Event="Button.Click" Handler="Button_Click"/>
</Style>
</ListBox.ItemContainerStyle>-->
</ListBox>
</Grid>
ViewModel
private ICommand closeButton;
public ICommand CloseButton
{
get
{
if (this.closeButton == null)
{
this.closeButton = new RelayCommand<object>(this.ExecuteCloseButton);
}
return this.closeButton;
}
}
private void ExecuteCloseButton(object err)
{
}
I have a control - ItemsControl that was binding to ObservableCollection of a simple model,
I want that it's itemscontrol will have a capability to insert dircetion from bottom to top, How to i can implement that?
Currently, Every insertion to itemscontrol starts from the top to bottom, but i want to change that..
<Window >
<Window.Resources>
<DataTemplate x:Key="ModelTemplate" DataType="Model:Model">
<Grid
Tag="{Binding Path=Id}"
Background="Transparent">
<Border
Name="border"
Background="#2a3345"
BorderThickness="0"
CornerRadius="10"
Margin="10">
<Border.Effect>
<DropShadowEffect
ShadowDepth="0"
Opacity="0.8"
BlurRadius="10"/>
</Border.Effect>
<Grid
Height="100"
Width="280"
Margin="6">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock
Grid.Column="1"
Text="{Binding Path=Title}"
TextOptions.TextRenderingMode="ClearType"
TextOptions.TextFormattingMode="Display"
Foreground="White"
FontFamily="Arial"
FontSize="14"
FontWeight="Bold"
VerticalAlignment="Center"
Margin="2,4,4,2"
TextWrapping="Wrap"
TextTrimming="CharacterEllipsis" />
<TextBlock
Grid.Row="1"
Grid.Column="1"
Text="{Binding Path=Message}"
TextOptions.TextRenderingMode="ClearType"
TextOptions.TextFormattingMode="Display"
Foreground="White"
FontFamily="Arial"
VerticalAlignment="Center"
Margin="2,2,4,4"
TextWrapping="Wrap"
TextTrimming="CharacterEllipsis"/>
</Grid>
</Border>
</Grid>
</DataTemplate>
</Window.Resources>
<Grid>
<ItemsControl
FocusVisualStyle="{x:Null}"
ItemsSource="{Binding SimpleCollection}"
ItemTemplate="{StaticResource ModelTemplate}" >
</ItemsControl>
</Grid>
The solution is override ItemsControl's ItemsPanel as follows:
<Window >
<Window.Resources>
<ScaleTransform ScaleY="-1" x:Key="Transform"/>
<DataTemplate x:Key="ModelTemplate" DataType="Model:Model">
<Grid
LayoutTransform="{StaticResource Transform}"
Tag="{Binding Path=Id}"
Background="Transparent">
<Border
Name="border"
Background="#2a3345"
BorderThickness="0"
CornerRadius="10"
Margin="10">
<Border.Effect>
<DropShadowEffect
ShadowDepth="0"
Opacity="0.8"
BlurRadius="10"/>
</Border.Effect>
<Grid
Height="100"
Width="280"
Margin="6">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock
Grid.Column="1"
Text="{Binding Path=Title}"
TextOptions.TextRenderingMode="ClearType"
TextOptions.TextFormattingMode="Display"
Foreground="White"
FontFamily="Arial"
FontSize="14"
FontWeight="Bold"
VerticalAlignment="Center"
Margin="2,4,4,2"
TextWrapping="Wrap"
TextTrimming="CharacterEllipsis" />
<TextBlock
Grid.Row="1"
Grid.Column="1"
Text="{Binding Path=Message}"
TextOptions.TextRenderingMode="ClearType"
TextOptions.TextFormattingMode="Display"
Foreground="White"
FontFamily="Arial"
VerticalAlignment="Center"
Margin="2,2,4,4"
TextWrapping="Wrap"
TextTrimming="CharacterEllipsis"/>
</Grid>
</Border>
</Grid>
</DataTemplate>
<ItemsPanelTemplate x:Key="ItemsPanelTemplateVerticalAlignment">
<StackPanel VerticalAlignment="Bottom" LayoutTransform="{StaticResource Transform}"/>
</ItemsPanelTemplate>
</Window.Resources>
<Grid>
<ItemsControl
FocusVisualStyle="{x:Null}"
ItemsSource="{Binding SimpleCollection}"
ItemTemplate="{StaticResource ModelTemplate}"
ItemsPanel="{StaticResource ItemsPanelTemplateVerticalAlignment}"/>
</Grid>
</Window>
The order of items in ItemsControl is the same as in ObservableCollection. Thus, if you do Collection.Insert(0, item), new item in ItemsControl will appear on the top.
I have grid with four texboxs like these :
And I would to get this:
I have tried to play with column span but with no success :(
<Grid Margin="20,0,0,20" VerticalAlignment="Top" HorizontalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.ColumnSpan="1" Grid.Row="0" Grid.Column="0" Margin="0,0,10,0" x:Name="TxtBox_CodeTiers" TextWrapping="Wrap" Text="{Binding m_strCode}" HorizontalAlignment="Stretch" VerticalAlignment="Top" FontSize="23"/>
<TextBlock Grid.ColumnSpan="1" Grid.Row="0" Grid.Column="1" Margin="0,0,10,0" x:Name="TxtBox_NomTiers" TextWrapping="Wrap" Text="{Binding m_strNom}" HorizontalAlignment="Stretch" VerticalAlignment="Top" FontSize="23" />
<TextBlock Grid.Row="1" Grid.Column="0" Margin="0,0,05,0" x:Name="TxtBox_CPostal" TextWrapping="Wrap" Text="{Binding m_strCpostal}" HorizontalAlignment="Stretch" VerticalAlignment="Top" Foreground="{StaticResource PhoneDisabledBrush}"/>
<TextBlock Grid.Row="1" Grid.Column="1" Margin="0,0,05,0" x:Name="TxtBox_Ville" TextWrapping="Wrap" Text="{Binding m_strVille}" HorizontalAlignment="Stretch" VerticalAlignment="Top" Foreground="{StaticResource PhoneDisabledBrush}"/>
</Grid>
It better with this :)
<Grid Margin="12,0,0,20" VerticalAlignment="Top" HorizontalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.ColumnSpan="2" x:Name="TxtBox_CodeTiers" Margin="0,0,20,0" TextWrapping="Wrap" Text="{Binding m_strCode}" HorizontalAlignment="Stretch" VerticalAlignment="Top" FontSize="23" Loaded="TxtBlock_Loaded"/>
<TextBlock Grid.Row="0" Grid.Column="2" x:Name="TxtBox_NomTiers" TextWrapping="Wrap" Text="{Binding m_strNom}" HorizontalAlignment="Stretch" VerticalAlignment="Top" FontSize="23" Loaded="TxtBlock_Loaded"/>
<TextBlock Grid.Row="1" Grid.Column="0" x:Name="TxtBox_CPostal" Margin="0,0,20,0" TextWrapping="Wrap" Text="{Binding m_strCpostal}" HorizontalAlignment="Stretch" VerticalAlignment="Top" Foreground="{StaticResource PhoneDisabledBrush}" Loaded="TxtBlock_Loaded"/>
<TextBlock Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" x:Name="TxtBox_Ville" TextWrapping="Wrap" Text="{Binding m_strVille}" HorizontalAlignment="Stretch" VerticalAlignment="Top" Foreground="{StaticResource PhoneDisabledBrush}" Loaded="TxtBlock_Loaded"/>
</Grid>
You will probably need to add another column for the "C" and "D" boxes to line up against, then just set the ColumnSpan on the "A" box to span the new column
<Grid Margin="20,0,0,20" VerticalAlignment="Top" HorizontalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="121*"/>
<ColumnDefinition Width="52*"/>
<ColumnDefinition Width="190*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.ColumnSpan="2" x:Name="TxtBox_CodeTiers" TextWrapping="Wrap" Text="AAAAAAAAA" HorizontalAlignment="Stretch" VerticalAlignment="Top" FontSize="23"/>
<TextBlock Grid.Row="0" Grid.Column="2" x:Name="TxtBox_NomTiers" TextWrapping="Wrap" Text="BBBBBBBB" HorizontalAlignment="Stretch" VerticalAlignment="Top" FontSize="23" />
<TextBlock Grid.Row="1" Grid.Column="0" x:Name="TxtBox_CPostal" TextWrapping="Wrap" Text="CCCCCCCCCCC" HorizontalAlignment="Stretch" VerticalAlignment="Top" Foreground="{StaticResource PhoneDisabledBrush}"/>
<TextBlock Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" x:Name="TxtBox_Ville" TextWrapping="Wrap" Text="DDDDDDDDD" HorizontalAlignment="Stretch" VerticalAlignment="Top" Foreground="{StaticResource PhoneDisabledBrush}" />
</Grid>
You can use in the second grid row StackPanel:
<Grid Margin="20,0,0,20" VerticalAlignment="Top" HorizontalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.ColumnSpan="1" Grid.Row="0" Grid.Column="0" Margin="0,0,10,0" x:Name="TxtBox_CodeTiers" TextWrapping="Wrap" Text="{Binding m_strCode}" HorizontalAlignment="Stretch" VerticalAlignment="Top" FontSize="23"/>
<TextBlock Grid.ColumnSpan="1" Grid.Row="0" Grid.Column="1" Margin="0,0,10,0" x:Name="TxtBox_NomTiers" TextWrapping="Wrap" Text="{Binding m_strNom}" HorizontalAlignment="Stretch" VerticalAlignment="Top" FontSize="23" />
<StackPanel Orientation="Horizontal" Grid.Row="1" Grid.ColumnSpan="2">
<TextBlock Margin="0,0,05,0" x:Name="TxtBox_CPostal" TextWrapping="Wrap" Text="{Binding m_strCpostal}" HorizontalAlignment="Stretch" VerticalAlignment="Top" Foreground="{StaticResource PhoneDisabledBrush}"/>
<TextBlock Margin="0,0,05,0" x:Name="TxtBox_Ville" TextWrapping="Wrap" Text="{Binding m_strVille}" HorizontalAlignment="Stretch" VerticalAlignment="Top" Foreground="{StaticResource PhoneDisabledBrush}"/>
</StackPanel>
</Grid>
Bars move, but the content does not scroll.
Any ideas?
I want to create a work schedule
<Window x:Class="WpfMiGantt.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525" xmlns:my="http://schemas.microsoft.com/winfx/2006/xaml/presentation/ribbon">
<Grid ShowGridLines="True">
<ScrollViewer HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible" >
<Border Width="1000" Height="1000"/>
</ScrollViewer >
<Grid ShowGridLines="True">
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<Grid Grid.Row="1" ShowGridLines="True" >
<Grid.ColumnDefinitions >
<ColumnDefinition Width="60" />
<ColumnDefinition Width="60" />
<ColumnDefinition Width="60"/>
<ColumnDefinition Width="60"/>
<ColumnDefinition Width="60"/>
<ColumnDefinition Width="60"/>
<ColumnDefinition Width="60"/>
<ColumnDefinition Width="60"/>
<ColumnDefinition Width="60"/>
<ColumnDefinition Width="60"/>
<ColumnDefinition Width="60"/>
<ColumnDefinition Width="60"/>
<ColumnDefinition Width="60"/>
<ColumnDefinition Width="60"/>
<ColumnDefinition Width="60"/>
<ColumnDefinition Width="60"/>
<ColumnDefinition Width="60"/>
<ColumnDefinition Width="60"/>
<ColumnDefinition Width="60"/>
<ColumnDefinition Width="60"/>
</Grid.ColumnDefinitions>
<my:RibbonTextBox Height="23" Label="6:00" Grid.Column="0" Grid.Row="0" HorizontalAlignment="Left" Margin="0" Name="ribbonTextBox0" VerticalAlignment="Center" />
<my:RibbonTextBox Height="23" Label="6:30" Grid.Column="1" Grid.Row="0" HorizontalAlignment="Left" Margin="0" Name="ribbonTextBox1" VerticalAlignment="Center" />
<my:RibbonTextBox Height="23" Label="7:00" Grid.Column="2" Grid.Row="0" HorizontalAlignment="Left" Margin="0" Name="ribbonTextBox2" VerticalAlignment="Center" />
<my:RibbonTextBox Height="23" Label="7:30" Grid.Column="3" Grid.Row="0" HorizontalAlignment="Left" Margin="0" Name="ribbonTextBox3" VerticalAlignment="Center" />
<my:RibbonTextBox Height="23" Label="8:00" Grid.Column="4" Grid.Row="0" HorizontalAlignment="Left" Margin="0" Name="ribbonTextBox4" VerticalAlignment="Center" />
<my:RibbonTextBox Height="23" Label="8:30" Grid.Column="5" Grid.Row="0" HorizontalAlignment="Left" Margin="0" Name="ribbonTextBox5" VerticalAlignment="Center" />
<my:RibbonTextBox Height="23" Label="9:00" Grid.Column="6" Grid.Row="0" HorizontalAlignment="Left" Margin="0" Name="ribbonTextBox6" VerticalAlignment="Center" />
<my:RibbonTextBox Height="23" Label="10:00" Grid.Column="7" Grid.Row="0" HorizontalAlignment="Left" Margin="0" Name="ribbonTextBox7" VerticalAlignment="Center" />
<my:RibbonTextBox Height="23" Label="10:30" Grid.Column="8" Grid.Row="0" HorizontalAlignment="Left" Margin="0" Name="ribbonTextBox8" VerticalAlignment="Center" />
<my:RibbonTextBox Height="23" Label="11:00" Grid.Column="9" Grid.Row="0" HorizontalAlignment="Left" Margin="0" Name="ribbonTextBox9" VerticalAlignment="Center" />
<my:RibbonTextBox Height="23" Label="11:30" Grid.Column="10" Grid.Row="0" HorizontalAlignment="Left" Margin="0" Name="ribbonTextBox10" VerticalAlignment="Center" />
<my:RibbonTextBox Height="23" Label="12:00" Grid.Column="11" Grid.Row="0" HorizontalAlignment="Left" Margin="0" Name="ribbonTextBox11" VerticalAlignment="Center" />
<my:RibbonTextBox Height="23" Label="12:30" Grid.Column="12" Grid.Row="0" HorizontalAlignment="Left" Margin="0" Name="ribbonTextBox12" VerticalAlignment="Center" />
<my:RibbonTextBox Height="23" Label="13:00" Grid.Column="13" Grid.Row="0" HorizontalAlignment="Left" Margin="0" Name="ribbonTextBox13" VerticalAlignment="Center" />
<my:RibbonTextBox Height="23" Label="13:30" Grid.Column="14" Grid.Row="0" HorizontalAlignment="Left" Margin="0" Name="ribbonTextBox14" VerticalAlignment="Center" />
<my:RibbonTextBox Height="23" Label="14:00" Grid.Column="15" Grid.Row="0" HorizontalAlignment="Left" Margin="0" Name="ribbonTextBox15" VerticalAlignment="Center" />
<my:RibbonTextBox Height="23" Label="14:30" Grid.Column="16" Grid.Row="0" HorizontalAlignment="Left" Margin="0" Name="ribbonTextBox16" VerticalAlignment="Center" />
<my:RibbonTextBox Height="23" Label="15:00" Grid.Column="17" Grid.Row="0" HorizontalAlignment="Left" Margin="0" Name="ribbonTextBox17" VerticalAlignment="Center" />
</Grid>
<my:RibbonButton Label="Fecha" Grid.Column="0" Grid.Row="0" Content="Button" Height="30" HorizontalAlignment="Center" Margin="0" Name="ribbonButton0" VerticalAlignment="Center" Width="Auto" />
<my:RibbonButton Label="" Grid.Column="0" Grid.Row="1" Content="Button" Height="30" HorizontalAlignment="Center" Margin="0" Name="ribbonButton1" VerticalAlignment="Top" Width="75" />
<my:RibbonButton Content="Button" Grid.Column="2" Grid.ColumnSpan="2" Height="23" HorizontalAlignment="Left" Margin="38,8,0,0" Name="ribbonButton2" VerticalAlignment="Top" Width="75" />
</Grid>
</Grid>
</Window>
I think the order of the lines is the key.
PD: Have you seen any similar project in codeplex or with WPF? 4
I suspect you want the scroll bars to act on the Grid. You will have to have the Grid in the ScrollViewer in that case
<ScrollViewer HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible" >
<Grid ShowGridLines="True" Width="1000" Height="1000">
...rest of grid content
</Grid>
</ScrollViewer >
I have this window:
My problem is that when the number is larger than 2 digits, it pushes the red rectangle to
the right. and I would like it to act like that:
The rectangle must not been pushed to the right.
This is my XAML:
<StackPanel>
<Border BorderThickness="1" BorderBrush="Beige">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" Grid.Column="1">
<TextBlock Text="1" VerticalAlignment="Top" />
<Rectangle Width="20" Height="20" Fill="Red" VerticalAlignment="Top" />
</StackPanel>
</Grid>
</Border>
<Border BorderThickness="1" BorderBrush="Beige">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" Grid.Column="1" >
<TextBlock Text="1123" VerticalAlignment="Top" />
<Rectangle Width="20" Height="20" Fill="Red" VerticalAlignment="Top" />
</StackPanel>
</Grid>
</Border>
</StackPanel>
<StackPanel>
<Border BorderThickness="1" BorderBrush="Beige">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30" />
<ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Text="1" VerticalAlignment="Top" Grid.Column="0" Grid.Row="0" HorizontalAlignment="Right"/>
<Rectangle Width="20" Height="20" Fill="Red" Grid.Column="1" Grid.Row="0"/>
<TextBlock Text="1123" VerticalAlignment="Top" Grid.Column="0" Grid.Row="1" HorizontalAlignment="Right"/>
<Rectangle Width="20" Height="20" Fill="Red" Grid.Column="1" Grid.Row="1"/>
</Grid>
</Border>
</StackPanel>