如图,点击按钮动态生成的TextBlock,右键菜单怎么设置该TextBlock的字体大小
我的源代码:
1 //按钮 2 private void buttonLeft_Click_1(object sender, RoutedEventArgs e) 3 { 4 TextBlock tb233 = new TextBlock(); 5 tb233.Text = "测试 /n ceshi"; 6 tb233.Name = "dddd"; 7 tb233.Margin = new Thickness(10, 170, 10, 0); 8 tb233.MouseRightButtonDown += MouseRightButtonDown_1; 9 grid1.Children.Add(tb233); 10 } 11 12 private void MouseRightButtonDown_1(object sender, MouseButtonEventArgs e) 13 { 14 TextBlock tb = sender as TextBlock; 15 ContextMenu cm = new ContextMenu(); 16 cm.Width = (double)220; 17 cm.Height = (double)200; 18 for (int i = 3; i <= 20; i++) 19 { 20 MenuItem mi = new MenuItem { Header = "字号:" + i }; 21 mi.Name = "m" + i; 22 cm.Items.Add(mi); 23 } 24 tb.ContextMenu = cm; 25 }
已经在CSDN问过,回复说直接设置TextBlock的FontSize,问题是可以直接设置我也不会问了,谁会给解答下