0
我製作了一個主頁並使用用戶組件來實現母版頁網站的樣式。我做了一個下拉組合框允許用戶在組合框中選擇他們的角色,我可能知道是否可以用XAML旁邊的C#代碼調用另一個用戶控件,而我需要執行一些邏輯語句。Silverlight組合框SelectedIndex已更改加載其他控件組件
我有一個母版頁,加載另一個組件與此組合框:
<ComboBox x:Name="cbRole" Height="30" Margin="8,8,8,100" VerticalAlignment="Top" ToolTipService.ToolTip="Please select your role to login" SelectionChanged="cbRole_SelectionChanged">
<ComboBoxItem Content="Admin"/>
<ComboBoxItem Content="Lecturer"/>
<ComboBoxItem Content="Student"/>
</ComboBox>
和母版頁與該行
<betata_Views_Sidebar:Sidebar/>
加載組合框,然後我得到了怎樣的一個問題做到這一點 - >
private void cbRole_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
int x = cbRole.SelectedIndex;
if (x == 0)
{
<betata_Views_Sidebar:Sidebar_Admin/>
}
else if (x == 1)
{
<betata_Views_Sidebar:Sidebar_Lecturer/>
}
else if (x == 2)
{
<betata_Views_Sidebar:Sidebar_Student/>
}
else
{
...
}
}
ouch>。
1myb
沒問題,很高興能幫到你! – stuartmclark
肯定= D你幫助= P上次我以這種方式做了,但我忘記了>。< – 1myb