Is there any Windows Store apps that's similar to ASP.NET ImageMap control
I want to have an image with defined clickable regions, when a region is clicked the event gets fired.
you can use this:
Image image = new Image();
image.Source = new BitmapImage(new Uri("ms-appx:///Assets/images.png"));
image.Width = 50;
image.Height = 50;
image.Tapped += new TappedEventHandler(pushpin_tapped);
MapLayer.SetPosition(image, new Location(latitude, longitude));
layer.Children.Add(image);
private void pushpin_tapped(object sender, TappedRoutedEventArgs e)
{
//you can handle your event here
}
for multiple events or ui-elements you can define a user control.Hope this can help
Related
we are using chromiumwebbrowser in WPf application, added DragEnter event handler to the chromiumwebbrowser and call come to us.
wanted to change the cursor,
private void Browser_DragEnter(object sender, DragEventArgs e)
{
var currCursor = Browser.Cursor;
if (e.Effects == DragDropEffects.Move)
{
//Mouse.OverrideCursor = Cursors.Hand;
// Mouse.SetCursor(Cursors.Hand);
Debug.Write("DragDropEffects.Move\n");
}
else
Mouse.SetCursor(Cursors.Hand);
Mouse.OverrideCursor = Cursors.Pen;
Browser.Cursor = Cursors.Pen;
//Mouse.Capture(Browse);
e.Handled = true;
}
nothing works, could some help would solve this issue
I'm using Xamarin.Forms mixed with some native Xamarin code. Now I'd like to get a UIButton instance from a Xamarin.Forms.Button. How can I do that?
In the Clicked event handler, I can see
void Share_Clicked(object sender, System.EventArgs e)
{
var button = sender as Xamarin.Forms.Button;
if(button.EffectControlProvider != null)
{
}
}
I can see EffectControlProvider.Controller is actually of UIButton type but I can't convert to it.
Is there any funciton like ToNative to get the UIButton?
Refer to Referring to Native Views from Code.
#if __IOS__
var wrapper = (Xamarin.Forms.Platform.iOS.NativeViewWrapper)contentViewButtonParent.Content;
var button = (UIKit.UIButton)wrapper.NativeView;
button.SetTitle("Scale and Rotate Text", UIKit.UIControlState.Normal);
button.SetTitleColor(UIKit.UIColor.Black, UIKit.UIControlState.Normal);
#endif
Notice:this code is only used in Shared Access Project.
Is there a working example for drawing an image inside a steema teechart in xamarin forms? I am really struggling with this.
It doesn't work either assigning an image to the back wall or panel:
var backImage = new Image();
backImage.Source = ImageSource.FromUri(new Uri("http://www.steema.com/uploads/news/xamarinforms_280x210.png"));
tChart1.Walls.Back.Gradient.Visible = false;
tChart1.Walls.Back.Image = backImage;
tChart1.Panel.Gradient.Visible = false;
tChart1.Panel.Image = backImage;
nor drawing it directly on the canvas:
void tChart1_BeforeDrawSeries(object sender, Graphics3D g)
{
Rectangle chartRect = tChart1.Chart.ChartRect;
var backImage = new Image();
backImage.Source = ImageSource.FromUri(new Uri("http://www.steema.com/uploads/news/xamarinforms_280x210.png"));
g.Draw(chartRect, chartRect, backImage, false);
}
So I have added this to the bug list (bug 1299). Happens both in iOS and Android.
I want to display a drop down menu when a user clicks a button. Something like comboBox but instead of the comboBox its a button. How can I do it??
I solved it using PopupMenu. Here is the code for other's reference.
public static Rect GetElementRect(FrameworkElement element)
{
GeneralTransform buttonTransform = element.TransformToVisual(null);
Point point = buttonTransform.TransformPoint(new Point());
return new Rect(point, new Size(element.ActualWidth, element.ActualHeight));
}
private async void Button_Click(object sender, RoutedEventArgs e)
{
var menu = new PopupMenu();
menu.Commands.Add(new UICommand("Label", (command) =>
{
//do work
}));
// We don't want to obscure content, so pass in a rectangle representing the sender of the context menu event.
// We registered command callbacks; no need to handle the menu completion event
var chosenCommand = await menu.ShowForSelectionAsync(GetElementRect((FrameworkElement)sender));
if (chosenCommand == null) // The command is null if no command was invoked.
{
}
}
Milan,
You'll need to create a custom control or a user control that combines a button and a popup. You could also just implement this in-place with a button and popup. I suggest you look at Callisto's Menu control and start from there to implement your dropdown menu:
Callisto controls (includes a Menu)
I´m writing on a webpart for sharepoint, so I have to generate a Datagrid problematically.
The Situation is that I get a Dataview, generate the Gris and bind the Data.
One column should show a Image, so I have to generate a template column with item template.
So code looks like this:
//Instantiate the DataGrid, and set the DataSource
_grdResults = new DataGrid();
_grdResults.AutoGenerateColumns = false;
_grdResults.DataSource = view;
TemplateColumn colPic = new TemplateColumn();
colPic.HeaderText = "Image";
I found dozens of example for asp to create the item-template, but how construct one in code and bind it´s ImageUrl to "imgURL" of the Dataview?
thanks for any advice
Ren
You need to create a class that implements that ITemplate interface.
public class TemplateImplementation : ITemplate
{
public void InstantiateIn(Control container)
{
Image image = new Image();
image.DataBinding += Image_DataBinding;
container.Controls.Add(image);
}
void Image_DataBinding(object sender, EventArgs e)
{
Image image = (Image)sender;
object dataItem = DataBinder.GetDataItem(image.NamingContainer);
// If the url is a property of the data item, you can use this syntax
//image.ImageUrl = (string)DataBinder.Eval(dataItem, "ThePropertyName");
// If the url is the data item then you can use this syntax
image.ImageUrl = (string)dataItem;
}
}
You then set your ItemTemplate to an instance of this class.
colPic.ItemTemplate = new TemplateImplementation();