我的項目中有一個奇怪的問題。有從usercontrol和菜單欄(也usercontrol)製成的頁面。用戶控件中的用戶控件wpf無響應
這裏是我的用戶,它包含幾個按鈕
public partial class UpperBar : UserControl
{
public UpperBar()
{
InitializeComponent();
}
public event EventHandler EventbtClicked;
private void btConnect_Click(object sender, System.Windows.RoutedEventArgs e)
{
EventbtClicked(this, e);
}
}
我說這在我的頁面如下:
<local:UpperBar VerticalAlignment="Top" Grid.Row="0" Height="78" Grid.ColumnSpan="3" Margin="0,2,0,0"/>
而且在我的網頁試圖調用事件:
public PageStatus()
{
InitializeComponent();
Plc.ExecuteRefresh += new EventHandler(RefreshLeds);
UpperBar.EventbtCliced += new EventHandler(UpperBatButtonClick);
}
protected void UpperBarButtonClick(object sender, EventArgs e)
{
//do something
}
但是我無法使用此UpperBar.EventbtCliced
訪問我的活動,爲什麼?
是什麼Plc的?我沒有看到你在xaml中命名你的控件 –
我認爲這是'EventbtCliced'是一個錯字,你的意思是:'EventbtClicked'? – CodingGorilla