最近在wpf中引用visifire Charts 控件的时候发现水印文字很讨厌,网上找了n中办法,大多说重写LoadWatermark方法,下面是重写LoadWatermark方法的解决方案:
首先,新建一个类,继承自Chart,重写LoadWatermark方法, 1 public class MyCharts:Chart 2 { 3 protected override void LoadWatermark() 4 { 5 //base.LoadWatermark(); 6 } 7 8 //private bool _watermark=false; 9 10 public MyCharts() 11 { 12 //this.Watermark = false; 13 } 14 15 //public override bool Watermark 16 //{ 17 // get; 18 // set; 19 //} 20 21 } 再创建图表实例的时候就不能new Chart实例了,直接使用MyCharts, 1 Chart chart = new MyCharts(); 2 //设置高度和宽度 3 chart.Width = 500; 4 chart.Height = 400; 5 chart.ToolBarEnabled = false;//工具栏 6 chart.ScrollingEnabled = false;//滚动条 7 chart.View3D = true;
<Application.Resources> <Style TargetType="TextBlock"> <Setter Property="Visibility" Value="Visible"> </Setter> <Style.Triggers> <Trigger Property="Text" Value="Visifire Trial Edition"> <Trigger.Setters> <Setter Property="Visibility" Value="Collapsed"></Setter> </Trigger.Setters> </Trigger> </Style.Triggers> </Style> </Application.Resources>
大家可以试一试哦!