Exemple #1
0
        static void OnContentPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            CFree c = (CFree)d;

            if (e.NewValue != null)
            {
                ApplyCellStyle(e.NewValue);
                if (e.NewValue is IFreeCell fc)
                {
                    fc.Owner = c;
                }
            }
        }
Exemple #2
0
        protected override void OnLoadTemplate()
        {
            Grid root = (Grid)GetTemplateChild("RootGrid");

            if (root == null)
            {
                return;
            }

            // 为uno节省一级ContentPresenter!
            if (root.Children.Count > 1)
            {
                root.Children.RemoveAt(0);
            }

            if (Content is FrameworkElement con)
            {
                CFree.ApplyCellStyle(con);
                // 左上空出边线
                var margin = con.Margin;
                con.Margin = new Thickness(margin.Left + 1, margin.Top + 1, margin.Right, margin.Bottom);
                root.Children.Insert(0, con);
            }
            else
            {
                StackPanel sp = new StackPanel {
                    Orientation = Orientation.Horizontal, Margin = new Thickness(10)
                };
                TextBlock tb = new TextBlock {
                    FontFamily = Res.IconFont, Text = "\uE02D", VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(0, 0, 4, 0)
                };
                sp.Children.Add(tb);
                tb = new TextBlock {
                    Text = (Content != null ? Content.ToString() : ""), TextWrapping = TextWrapping.NoWrap, VerticalAlignment = VerticalAlignment.Center
                };
                sp.Children.Add(tb);
                root.Children.Insert(0, sp);
            }
        }