I am quite new in Silverlight and I've got a problem with a HyperlinkButton. So far, I display my data (a list of patients) in a DataGrid using a button. What I want to do, is to navigate to another page, clicking any row, in which I'll display the details
for that particular patient. I've tried it with a HyperlinkButton, and it does navigate to another page, but doesn't show the data, and gives me the following error:
The resource cannot be found
Description:
HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
ok you need UriMapping to map Uri to an actual implentation of your PatientDetails page and pass your patientId. Put this in your mapping in your Frame:
I assume here that you named your PatientDetails page PatientDetailsPage.xaml. In your PatientDetailsPage you can query the patientid by overriding the OnNavigatedTo method.
protected override void OnNavigatedTo(NavigationEventArgs e)
{
var x = NavigationContext.QueryString["patientid"];
int patientid;
if(Int32.TryParse(x, out projectId)))
{
//load the data associated with patientid here
}
}
Jan Hannemann
Research Associate University of Victoria
Please remember to mark the replies as answers if they answered your question
lbentabol
0 Points
2 Posts
Problem firing a new page using a HyperlinkButton in a DataGrid (Error: The resource cannot be fo...
Mar 10, 2011 03:34 PM | LINK
Hi.
I am quite new in Silverlight and I've got a problem with a HyperlinkButton. So far, I display my data (a list of patients) in a DataGrid using a button. What I want to do, is to navigate to another page, clicking any row, in which I'll display the details for that particular patient. I've tried it with a HyperlinkButton, and it does navigate to another page, but doesn't show the data, and gives me the following error:
The resource cannot be found
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /PatientDetails/6
Here is the XAML from where I call the page:
<data:DataGrid x:Name="dgResults" Margin="8" Grid.Row="1" IsReadOnly="True" AutoGenerateColumns="False"
ItemsSource="{Binding ElementName=patientDomainDataSource, Path=Data}" RowDetailsVisibilityMode="VisibleWhenSelected">
<data:DataGrid.Columns>
<data:DataGridTemplateColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Width="Auto">
<data:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<HyperlinkButton Content="(view)" TargetName="_blank" x:Name="btnView"
NavigateUri="{Binding Id_patient, StringFormat='/PatientDetails/\{0\}'}"
VerticalAlignment="Center"></HyperlinkButton>
</DataTemplate>
</data:DataGridTemplateColumn.CellTemplate>
</data:DataGridTemplateColumn>
<data:DataGridTextColumn Binding="{Binding Id_patiemt}" Header="ID"/>
<data:DataGridTextColumn Binding="{Binding Name}" Header="First Name"/>
<data:DataGridTextColumn Binding="{Binding LastName}" Header="Last Name"/>
</data:DataGrid.Columns>
</data:DataGrid>
And the XAML of the page where I want to navigate to is the following:
<Grid x:Name="LayoutRoot1" DataContext="{Binding SelectedItem, ElementName=dgResults}">
[...]
<TextBlock Margin="4,6,0,4"
VerticalAlignment="Center"
Text="First Name:"
TextAlignment="Right"
TextWrapping="Wrap"
Grid.ColumnSpan="2" Grid.Row="1" />
<TextBox Name="txtFirstName1"
Margin="2,2,12,2"
Grid.Column="2"
Grid.Row="1"
Text="Name"
TextWrapping="Wrap"
d:LayoutOverrides="Width, Height"
IsReadOnly="True"/>
<TextBlock Margin="5,9,510,11"
Text="Last Name:"
TextAlignment="Right"
TextWrapping="Wrap"
Grid.Row="2"
d:LayoutOverrides="Height"
Grid.ColumnSpan="3" />
<TextBox Name="txtLastName1"
Margin="2,2,12,2"
Grid.Column="2"
Text="{Binding LastName}"
TextWrapping="Wrap"
Grid.Row="2"
d:LayoutOverrides="Width, Height"
IsReadOnly="True"/>
</Grid>
Thanks in advance.
Lucía
HyperlinkButton datagrid silverlight4 navigate new page
bitdisaster
Participant
1474 Points
339 Posts
Re: Problem firing a new page using a HyperlinkButton in a DataGrid (Error: The resource cannot b...
Mar 10, 2011 04:25 PM | LINK
could you post the XAML for your URI mapping?
Research Associate University of Victoria
Please remember to mark the replies as answers if they answered your question
lbentabol
0 Points
2 Posts
Re: Re: Problem firing a new page using a HyperlinkButton in a DataGrid (Error: The resource cann...
Mar 10, 2011 05:24 PM | LINK
I don't have any Uri mapping code... :-S
bitdisaster
Participant
1474 Points
339 Posts
Re: Re: Problem firing a new page using a HyperlinkButton in a DataGrid (Error: The resource cann...
Mar 11, 2011 03:50 PM | LINK
ok you need UriMapping to map Uri to an actual implentation of your PatientDetails page and pass your patientId. Put this in your mapping in your Frame:
<sdk:UriMapper> <sdk:UriMapping Uri="/PatientDetails/{patientid}" MappedUri="/PatientDetailsPage.xaml?patientid={patientid}"/> </sdk:UriMapper>I assume here that you named your PatientDetails page PatientDetailsPage.xaml. In your PatientDetailsPage you can query the patientid by overriding the OnNavigatedTo method.
protected override void OnNavigatedTo(NavigationEventArgs e) { var x = NavigationContext.QueryString["patientid"]; int patientid; if(Int32.TryParse(x, out projectId))) { //load the data associated with patientid here } }Research Associate University of Victoria
Please remember to mark the replies as answers if they answered your question