Hello,
I am working on directing to new page in wizard on click of hyperlink in dynamic gird view data template.
I got some nice input specially adding events with XamlReader.Load() from http://www.telerik.com/forums/adding-click-event-handler-to-template link. Thank you for that!
Now, the problem is that my gird view (attached image) has "Add User" link which should open next page at very first time click but since there are total 5 links (dynamic-can be less or more) in first row , HyperlinkButtonClick() gets called 5 times and then it open new Add User page.
Here is the code:
string userDetailsTemplate =
"<DataTemplate xmlns='http://schemas.microsoft.com/client/2007'>" +
"<Grid HorizontalAlignment='Stretch'>" +
"<Grid.ColumnDefinitions>" +
"<ColumnDefinition />" +
"<ColumnDefinition />" +
"</Grid.ColumnDefinitions>" +
"<Grid.RowDefinitions>" +
"<RowDefinition />" +
"<RowDefinition />" +
"<RowDefinition />" +
"<RowDefinition />" +
"</Grid.RowDefinitions>" +
"<TextBlock Text='{Binding [Username], Source={StaticResource Labels}}' Visibility='{Binding " + entp + ".Username, Converter={StaticResource VisibilityConverter}}'/>" +
"<TextBlock Text='{Binding " + entp + ".Username}' Grid.Column='1' />" +
"<TextBlock Text='{Binding [Phone], Source={StaticResource Labels}}' Grid.Row='1' Visibility='{Binding " + entp + ".Phone, Converter={StaticResource VisibilityConverter}}'/>" +
"<TextBlock Text='{Binding " + entp + ".Phone}' Grid.Column='1' Grid.Row='1' />" +
"<TextBlock Text='{Binding [Email], Source={StaticResource Labels}}' Grid.Row='2' Visibility='{Binding " + entp + ".Email, Converter={StaticResource VisibilityConverter}}'/>" +
"<TextBlock Text='{Binding " + entp + ".Email}' Grid.Column='1' Grid.Row='2' />" +
"<HyperlinkButton Name='HLButton' Content='Add User' Visibility='{Binding " + entp + ".Username, Converter={StaticResource InvisibilityConverter}}' Grid.Row='3'/>" +
"</Grid>" +
"</DataTemplate>";
DataTemplate newDT = (DataTemplate)XamlReader.Load(userDetailsTemplate);
externalidCol.CellTemplate = newDT;
this.staffGridView.AddHandler(HyperlinkButton.MouseLeftButtonUpEvent, new MouseButtonEventHandler(HyperlinkButtonClick), true);
this.staffGridView.Columns.Add(externalidCol);
public void HyperlinkButtonClick(object sender, MouseButtonEventArgs e)
{
if (sender == null)
return;
var senderElement = e.OriginalSource as FrameworkElement;
var row = senderElement.ParentOfType<GridViewRow>();
XeRecord rec = row.Item as XeRecord;
selectStaff(rec);
}