簡體   English   中英

在所選按鈕上應用樣式

[英]apply a Style on the selected button

我有一個10個按鈕的列表,當我選擇那個按鈕時,我想在其中應用特定的樣式,我這樣做是:

private bool button1WasClicked = false;
private bool button2WasClicked = false;
private bool button3WasClicked = false;
.....
private void button1_Click(object sender, EventArgs e)
{
    button1WasClicked = true;
}

private void button2_Click(object sender, EventArgs e)
{
    button2WasClicked = true;
}



private void Page_Loaded(object sender, RoutedEventArgs e)
        {
        if (button1WasClicked)
    { 
        apply the style on Button1
        button1WasClicked = false;
    }
       if (button2WasClicked)
    { 
        apply the style on Button2
        button2WasClicked = false;
    }
...... //complete the list of other buttons
        }

我的問題是,是否可以使用其他方法將樣式應用到我的10個按鈕的所選按鈕上,而不是其他方法

我希望有人可以在這里幫助我..謝謝

這里有ToggleButton ,它帶有Checked屬性,並且對於Checked和Unchecked具有不同的VisualStates

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM