I want to add option to draw rectangle on image. But that is not problem. In order to get it working I need to use MouseDown, MouseUp and MouseLeave events of Image Control in WPF.
<DockPanel Name="dockPanel1" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="15">
<GroupBox Header="WebCam" Name="groupBox1" VerticalAlignment="Top" HorizontalAlignment="Left">
<Grid>
<Image HorizontalAlignment="Left" Margin="0" Name="pictureBoxMain" Stretch="Fill" VerticalAlignment="Top" MinHeight="240" MinWidth="320" StretchDirection="DownOnly" MaxWidth="960" MaxHeight="1200" MouseDown="pictureBoxMain_MouseDown" MouseUp="pictureBoxMain_MouseUp" MouseLeave="pictureBoxMain_MouseLeave" Panel.ZIndex="50" />
</Grid>
</GroupBox>
<StackPanel HorizontalAlignment="Right" Name="stackPanel2" VerticalAlignment="Top" DockPanel.Dock="Right" Margin="15,0,0,0">
<GroupBox Header="Controls" Name="groupBox2">
<StackPanel Name="stackPanel1">
<Button Content="Start" Height="23" Name="buttonStartStop" Width="120" Margin="0" Click="buttonStartStop_Click" />
<Button Content="Video Properties" Height="23" Name="buttonVideoProperties" Width="120" Margin="0" Click="buttonVideoProperties_Click" />
<Button Content="WebCam Settings" Height="23" Name="buttonWebCamSettings" Width="120" Margin="0" Click="buttonWebCamSettings_Click" />
</StackPanel>
</GroupBox>
<GroupBox Header="Motion Data" Name="groupBox3">
<StackPanel>
<Label Content="Strength: 0" x:Name="labelMotionStrength" />
<Label Content="Count: 0" x:Name="timesWasMotionCounter" />
</StackPanel>
</GroupBox>
</StackPanel>
</DockPanel>
I'm talking about events of "pictureBoxMain". Why those events never fire? I'm clicking on my image like crazy and still nothing. What should I do to make those event working?