您的位置:首页 > 其它

WinStore控件之Button、HyperlinkButton、RadioButton、CheckBox、progressBar、ScrollViewer、Slider

2014-10-08 15:58 483 查看
1、Button

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<StackPanel>
<Grid Name="controlGrid" Grid.Row="0" Grid.Column="0">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Grid.Row="0" Text="红色" Foreground="Red" FontSize="20" />
<Slider x:Name="redSlider" Grid.Column="0" Grid.Row="1" Foreground="Red" Minimum="0" Maximum="255" ValueChanged="OnSliderValueChanged" />
<TextBlock x:Name="redText" Grid.Column="0" Grid.Row="2" Text="0" Foreground="Red" FontSize="20"/>
<TextBlock Grid.Column="1" Grid.Row="0" Text="绿色" Foreground="Green" FontSize="20"    />
<Slider x:Name="greenSlider" Grid.Column="1" Grid.Row="1" Foreground="Green" Minimum="0" Maximum="255" ValueChanged="OnSliderValueChanged" />
<TextBlock x:Name="greenText" Grid.Column="1" Grid.Row="2" Text="0" Foreground="Green" FontSize="20" />
<TextBlock Grid.Column="2" Grid.Row="0" Text="蓝色" Foreground="Blue" FontSize="20"/>
<Slider x:Name="blueSlider" Grid.Column="2" Grid.Row="1" Foreground="Blue" Minimum="0" Maximum="255" ValueChanged="OnSliderValueChanged" />
<TextBlock x:Name="blueText" Grid.Column="2" Grid.Row="2" Text="0" Foreground="Blue" FontSize="20" />
</Grid>
<Ellipse Height="100" x:Name="ellipse1" Stroke="Black" StrokeThickness="1" Width="224" />
<TextBlock x:Name="textBlock1" Text="颜色" FontSize="26"/>
</StackPanel>
</Grid>


Slider

public MainPage()
{
InitializeComponent();
redSlider.Value = 128;
greenSlider.Value = 128;
blueSlider.Value = 128;
}

void OnSliderValueChanged(object sender, RangeBaseValueChangedEventArgs e)
{

Color clr = Color.FromArgb(255, (byte)redSlider.Value,
(byte)greenSlider.Value,
(byte)blueSlider.Value);
ellipse1.Fill = new SolidColorBrush(clr);
textBlock1.Text = clr.ToString();
redText.Text = clr.R.ToString("X2");
greenText.Text = clr.G.ToString("X2");
blueText.Text = clr.B.ToString("X2");

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐