Thursday, November 28, 2013

Separate an Image into areas is it possible ?

Hi, zakkar


You can define a usercontrol and override its OnPointerPressed

event. See some codes below:


User control in XAML:



<UserControl
x:Class="Combobox.MyUserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Combobox"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="400">

<Grid>
<Grid>
<Image Source="Assets/Logo.png" IsHitTestVisible="True" Stretch="Fill"/>
</Grid>
</Grid>
</UserControl>

MyUserControl1.cs:



public sealed partial class MyUserControl1 : UserControl
{
public MyUserControl1()
{
this.InitializeComponent();
}

protected override void OnPointerPressed(PointerRoutedEventArgs e)
{
Image image = e.OriginalSource as Image;
Debug.WriteLine("Current Point:X:{0} Y:{1}",
e.GetCurrentPoint(image).Position.X,
e.GetCurrentPoint(image).Position.Y);
// ...
base.OnPointerPressed(e);
}

}

Use the MyUserControl1 in MainPage:



<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<local:MyUserControl1/>
</Grid>

Best Wishes!






We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.

Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to &quot;Mark as Answer&quot; the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.



No comments:

Post a Comment