Saturday, 8 April 2017
Using Column and Row deffinations in WPF
WPF da Column va Row deffination lardan foydalanish
Window da ishlaganimizda yoki UserControlda ishlaganimizda
uni Row va Column larga ajratgan holda contentlarni joylashtirishimiz mumkin
buning uchun Grid quyidagi tartibda aniqlanishi lozim:
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="400" Name="column1"/>
<ColumnDefinition Width="*" Name="column2"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
</Grid>
Ushubu code yordamida biz Grid ni 2ta Column va 1ta Row ga ajratib yaratdik.
Endi Ixtiyoriy elementni add qilishni qaraymiz. Row yoki Column lar avtomatik
0 dan boshlab indexlangan boladi.
...
<Button x:Name="btnResult" Content="Результать" HorizontalAlignment="Left" Margin="78,16,0,0" VerticalAlignment="Top" Width="75" Click="btnResult_Click"
Grid.Column="0"/>
<Button x:Name="btnReport" Content="Отчёть" HorizontalAlignment="Left" Margin="78,16,0,0" VerticalAlignment="Top" Width="75" Click="btnReport_Click"
Grid.Column="1"/>
...
Demak, yuqoridagi code ning ma'nosi shundaki,
btnResult tugmasi 1-columnga add qilindi, btnResult esa 2-Column ga add qilindi.
Bu nima uchun kerak?
Biz Grid ni Column va Row lar yordamida xoxlagancha bolaklarga ajaratib har bir yacheykasiga content joylashtira olamiz!
Savol: Yacheykalarga Splitter qoyish mumkinmi? Ya'ni mouse bilan uning sizeni change qiboladimi?
Javob: Albatta boladi!
Masalan:
<Window x:Class="MySamples.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApplicationSample2"
mc:Ignorable="d"
Title="MainWindow" Height="728" Width="1024" WindowStartupLocation="CenterScreen"
WindowState="Maximized">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="400" Name="column1"/>
<ColumnDefinition Width="*" Name="column2"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Button x:Name="btnResult" Content="Результать" HorizontalAlignment="Left" Margin="78,16,0,0" VerticalAlignment="Top" Width="75" Click="btnResult_Click"
Grid.Column="0"/>
<ListBox Name="listBox1" Margin="0,50,0,0"
ItemsSource="{Binding Items}" Grid.Column="0" Width="380" Height="650">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Background="Aqua">
<Label Content="{Binding recNo}" Width="100"/>
<Button Content="{Binding Path=wellName}" Width="120" Background="AliceBlue"/>
<Button>
<Button.Content>
<TextBlock Text="{Binding Path=x0, StringFormat='X: {0}'}" Width="70"/>
</Button.Content>
</Button>
<Button>
<Button.Content>
<TextBlock Text="{Binding Path=y0, StringFormat='Y: {0}'}" Width="70"/>
</Button.Content>
</Button>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<GridSplitter Grid.Column="0"
HorizontalAlignment="Right"
Background="Green"
ShowsPreview="False"
Width="5" Height="Auto"/>
<TextBlock Text="this is second block" Grid.Column="1" Margin="10,0,0,0"/>
<ScrollViewer Grid.Column="1" CanContentScroll="True" Margin="0,0,0,0"
HorizontalAlignment="Left" VerticalAlignment="Top" VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Auto">
<Canvas Name="canvas1" Grid.Column="1" Width="1500" Height="950" HorizontalAlignment="Left"
VerticalAlignment="Top" Margin="0,0,0,0">
</Canvas>
</ScrollViewer>
</Grid>
</Window>
Subscribe to:
Post Comments (Atom)
Tasks and Threads
Differences Between Task And Thread: 1. The Thread class is used for creating and manipulating a thread in Windows. 2. A Task represents ...
-
Using User Controls in Windows Forms Applications Windows Formsdagi UserControl base-sinfidan foydalanib User Conrol hosil qilishimiz...
-
Differences Between Task And Thread: 1. The Thread class is used for creating and manipulating a thread in Windows. 2. A Task represents ...
-
Java toString() metodi Ixtiyoriy ob’yektni string(satr) ko’rinishida ifodalash uchun doimo toString() metodidan foydalanamiz toStr...
No comments:
Post a Comment
Note: only a member of this blog may post a comment.