编写 WPF 应用程序实现下列功能。
(1)单击产生 20 个随机数按钮显示 20 个 0-500 的随机数(含 0 和 500),并
利用数据绑定显示这 20 个数的最小值,平均值和最大值。
(
2
)最小值作为红色分量、平均值作为绿色分量、最大值作为蓝色分量,要求对
颜色的取值范围(
0-255
)进行验证,当分量值超过规定的范围时,用红色框将其
标注出来。
<Window x:Class="WpfApp10.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:WpfApp10"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Window.Resources>
<Style x:Key="txtStyle" TargetType="TextBox">
<Setter Property="Width" Value="50"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="true">
<Setter Property="ToolTip"
Value="{Binding (Validation.Errors)[0].ErrorContent,
RelativeSource={RelativeSource Self}}" />
</Trigger>
</Style.Triggers>
</Style>
<local:Database1 x:Key="src1"/>
</Window.Resources>
<StackPanel Margin="20">
<Button Name="btn" Content="单击产生20个随机数"
HorizontalAlignment="Left" Padding="10 5" Margin="10"/>
<GroupBox Header="20个随机数" Padding="10" Margin="10"
评论0
最新资源