是否有人使用右下方的“确定”和“取消”按钮创建标准对话框/登录窗口的任何示例。
我不确定是否使用StackPanels,网格或dockpanels。我知道使用Canvas通常不正确,因为您必须输入x和y值。
到目前为止我创建的是Ok和Cancel
的buttos <StackPanel Orientation="Horizontal"
FlowDirection="RightToLeft" Height="32">
<Button Width="72" TabIndex="45" Margin="2,2,2,2">Cancel</Button>
<Button Width="72" TabIndex="40" Margin="2,2,2,2">OK</Button>
</StackPanel>
我非常感谢这方面的任何帮助。
我想要创建的窗口类型是标准的对话窗口。
由于
答案 0 :(得分:0)
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock grid.row=1 grid.column=0 text="user name" />
<TextBlock grid.row=1 grid.column=1 text="password" />
<TextBox grid.row=2 grid.column=0 />
<TextBox grid.row=2 grid.column=1 />
<Button grid.row=3 grid.column=0 text="OK" />
<Button grid.row=3 grid.column=1 text="Cancel" />
</Grid>
答案 1 :(得分:0)
我更喜欢以下标记:
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="3*"/>
</Grid.ColumnDefinitions>
<Grid Grid.ColumnSpan="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock VerticalAlignment="Center">Username:</TextBlock>
<TextBlock VerticalAlignment="Center" Grid.Row="1">Password:</TextBlock>
<TextBox Grid.Column="1" />
<TextBox Grid.Row=1"" Grid.Column="1" />
</Grid>
<Button Grid.Row="1">Ok</Button>
<Button Grid.Row="1" Grid.Column="1">Cancel</Button>
</Grid>
是的,也可以将网格数量减少到1,但我认为没有任何意义。也可以使用StackPanel而不是外部Grid。
“最轻的标记”短语可以有不同的解释。最轻的开发人员是最简单明了的。计算机中最轻的是最快的初始化和渲染。至于给定的情况,差异实际上在1个额外的布局容器中。实际情况并非如此,以进行优化
答案 2 :(得分:0)
对于我的应用程序,我喜欢使用ChildWindow。然后在每个页面上,我可以验证用户是否已经过验证,如果不是这样,则弹出子窗口。如果您在silverlight中使用项目的导航类型,这也是很好用的书签。
<toolkit:BusyIndicator IsBusy="False" Name="LoginBusy" >
<Grid x:Name="LayoutRoot" Margin="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="189*" />
<ColumnDefinition Width="189*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="65*" />
<RowDefinition Height="32" />
<RowDefinition Height="32" />
<RowDefinition Height="26*" />
<RowDefinition Height="35" />
</Grid.RowDefinitions>
<Button x:Name="OKButton" Content="OK" Click="OKButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,0,0" Grid.Row="4" Grid.Column="1" TabIndex="3" />
<sdk:Label Grid.Row="1" Name="label1" HorizontalAlignment="Right" Content="Username" Margin="4" />
<sdk:Label Grid.Row="2" Name="label2" HorizontalAlignment="Right" Content="Password" Margin="4" />
<TextBox Grid.Column="1" Grid.Row="1" Name="Username" Margin="4" Text="{Binding Username,Mode=TwoWay}" TextChanged="TextInserted" TabIndex="1" />
<PasswordBox Grid.Column="1" Grid.Row="2" Name="Password" Margin="4" Password="{Binding Password,Mode=TwoWay}" PasswordChanged="TextInserted" TabIndex="2" />
<TextBlock Grid.Column="1" Grid.Row="3" Height="37" HorizontalAlignment="Left" Visibility="Collapsed" Margin="19,13,0,0" Name="ErrorBlock" Text="Authentication Failed." VerticalAlignment="Top" Width="161" Foreground="Red" FontWeight="Bold" />
<Button Grid.Row="4" Height="23" HorizontalAlignment="Left" Margin="46,4,0,0" Visibility="Collapsed" Name="button1" Content="CANCEL" VerticalAlignment="Top" Width="75" Click="CancelButton_Click" IsTabStop="False" />
<Image Name="image1" Stretch="Fill" Source="Images/logo.png" />
</Grid>
</toolkit:BusyIndicator>
这是我的子窗口的内容没有标题位。请注意,我直接绑定到实现InotifyPropertyChanged的用户对象。此外,当Web服务执行验证时,我启用忙指示符,以便用户看到他的请求正在处理。
干杯,