как добавить всплывающий текст в кнопку программно - PullRequest
0 голосов
/ 11 июня 2018

Я генерирую эту кнопку, и я хотел бы установить текст во всплывающем окне

            var button = new Button();            
            button.Height = height;
            button.Width = width;

            button.Margin = new Thickness(left, top, 0, 0);
            button.BorderBrush = new SolidColorBrush(Windows.UI.Colors.Red);
            button.BorderThickness = new Thickness(2);
            button.Background = new SolidColorBrush(Windows.UI.Colors.Transparent);
            button.Flyout = new Flyout();

как мне установить содержимое кнопки. Разветвление?

1 Ответ

0 голосов
/ 12 июня 2018

как настроить содержимое кнопки. Разветвление?

Вы можете передать экземпляр кнопки следующему методу.

public void AddFlyoutToBtn(Button TargetBtn)
{
    TargetBtn.Flyout = new Flyout()
    {
        Content = new StackPanel
        {
            Children =
            {
                new TextBlock
                {
                    Text = "All items will be removed. Do you want to continue?",
                    Margin = new Thickness(10, 10, 0, 0)
                 },
                new Button
                {
                    Content = "Yes, empty my cart"
                }
            }
        }
    };
}
...