xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WPF" Height="300" Width="300">
//File:Window.xaml.cs
using System.Windows;
using System.Windows.Input;
namespace WpfApplication1
{
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
private void Slider_MouseWheel(object sender, MouseWheelEventArgs e)
{
sldSlider.Value += (e.Delta > 0) ? 5 : -5;
}
private void Rectangle_MouseWheel(object sender, MouseWheelEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
double newWidth = shpRectangle.Width += (e.Delta > 0) ? 5 : -5;
if (newWidth < 10) newWidth = 10;
if (newWidth > 200) newWidth = 200;
shpRectangle.Width = newWidth;
}else{
double newHeight = shpRectangle.Height += (e.Delta > 0) ? 5 : -5;
if (newHeight < 10) newHeight = 10;
if (newHeight > 200) newHeight = 200;
shpRectangle.Height = newHeight;
}
}
}
}