Laxcus大数据技术 2020-05-27
MainWindow.xaml
主要注意的是三个地方(现在我对WPF基础知识不怎么数量)
https://blog.csdn.net/fantasiax/article/details/3499767
?
<Window x:Class="databinding001.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:databinding001" mc:Ignorable="d" x:Name="window" Title="CLR_Properties_Demo" Height="150" Width="300"> ? <Grid Margin="10"> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="15"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="10"/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> ? <!-- Row 0 --> <TextBlock Text="Your department" Grid.Row="0" Grid.Column="0"/> <TextBlock Text=":" Grid.Row="0" Grid.Column="1" HorizontalAlignment="Center"/> <TextBlock Text="{Binding Department, ElementName = window}" Margin="0 2" Grid.Row="0" Grid.Column="2"/> ? <!-- Row 1 --> <TextBlock Text="Your name" Grid.Row="1" Grid.Column="0"/> <TextBlock Text=":" Grid.Row="1" Grid.Column="1" HorizontalAlignment="Center"/> <TextBox Text="{Binding PersonName, ElementName=window, Mode=TwoWay}" Margin="0 2" Grid.Row="1" Grid.Column="2"/> ? <!-- Row 3 --> <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="3"> <Button Content="Submit" Margin="4" Width="80" Click="OnSubmit"/> <Button Content="Reset" Margin="4" Width="80" Click="OnReset"/> </StackPanel> </Grid> </Window> |
<ListBox Name="sideMenu" SelectedIndex="{Binding MenuSelectedIndex}" ItemsSource="{Binding MenuList}