Beispiel #1
0
        public KnowledgeWiki()
        {
            InitializeComponent();
            viewModel   = new KnowledgeWikiViewModel();
            DataContext = viewModel;

            foreach (var knowledge in viewModel.Knowledges)
            {
                Button button = new Button();
                button.Content = $" {knowledge.Knowledge} ";
                //button.Width = 160;
                button.Height = 40;
                button.Margin = new Thickness(10, 5, 10, 5);
                button.Name   = "btn" + knowledge.Id.Replace("-", "");
                button.Tag    = knowledge;
                Binding binding = new Binding()
                {
                    Source = knowledge,
                    Path   = new PropertyPath("Visibility"),
                    Mode   = BindingMode.TwoWay,
                    UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                };
                BindingOperations.SetBinding(button, Button.VisibilityProperty, binding);
                ButtonHelper.SetButtonStyle(button, ButtonStyle.Hollow);
                ButtonHelper.SetClickStyle(button, ClickStyle.Sink);
                ButtonHelper.SetCornerRadius(button, new CornerRadius(4));
                ButtonHelper.SetHoverBrush(button, "#00BCFF".ToColor().ToBrush());
                button.BorderBrush = "#20A0FF".ToColor().ToBrush();
                button.Foreground  = "#20A0FF".ToColor().ToBrush();
                button.Click      += Button_Click;
                this.content.Children.Add(button);
            }
        }
        private void ChbSink_CheckChanged(object sender, RoutedEventArgs e)
        {
            if (!IsLoaded)
            {
                return;
            }

            ButtonHelper.SetClickStyle(BtnCustom, ChbSink.IsChecked == true ? ClickStyle.Sink : ClickStyle.None);
            UpdateCode();
        }