我的代码中有两个超链接包含图像,当我清除第二个第一个工作但是当他们两个写这样的时候btnClose工作为btnnew。它意味着事件(btnAdd_Click)适用于他们两个,我不知道为什么
<HyperlinkButton x:Name="btnClose" Click="btnClose_Click">
<HyperlinkButton.RenderTransform>
<TranslateTransform />
</HyperlinkButton.RenderTransform>
<Canvas>
<Image Source="/ITStock;component/Images/undo.png" Height="20" Width="20"Margin="10,5,0,0"/>
</Canvas>
</HyperlinkButton>
<HyperlinkButton x:Name="btnNew" Click="btnAdd_Click" >
<HyperlinkButton.RenderTransform>
<TranslateTransform />
</HyperlinkButton.RenderTransform>
<Canvas>
<Image Source="/ITStock;component/Images/edit_add.png" Height="20" Width="20" Margin="45,5,0,0"/>
</Canvas>
</HyperlinkButton>
private void btnClose_Click(object sender, RoutedEventArgs e)
{
HtmlPage.Window.Invoke("OpenMainPage");
}
private void btnAdd_Click(object sender, RoutedEventArgs e)
{
stock = new SR_BLStock.Stock();
if (stock != null)
{
dgStock1.RowDetailsVisibilityMode = DataGridRowDetailsVisibilityMode.Collapsed;
Grid grUsc = new Grid();
grUsc.Margin = new Thickness(50);
Border b = new Border();
b.Name = "uscBorder";
b.Background = new SolidColorBrush(Colors.Black);
b.Opacity = 0.6;
NewStock usc = new NewStock(stock);
dgStock1.IsEnabled = false;
dg.IsEnabled = false;
grUsc.Children.Add(usc);
LayoutRoot.Children.Add(grUsc);
}
}