Skip to content

Commit 239ee46

Browse files
Merge pull request #2 from SyncfusionExamples/WPF-46193-Custom_annotation_sample
WPF-46193-Modify the KB sample.
2 parents 66b4438 + edde0f6 commit 239ee46

File tree

4 files changed

+29
-29
lines changed

4 files changed

+29
-29
lines changed

Custom_Annotation/MainWindow.xaml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,21 @@
2222
</chart:SfChart.SecondaryAxis>
2323

2424
<chart:SfChart.Annotations>
25-
<local:CustomTextAnnotation HorizontalTextAlignment="Stretch" VerticalTextAlignment="Stretch" X1="1.6" X2="1.6" Y1="18" Y2="20" Fill="White" IsHitTestVisible="False" CanDrag="True" CanResize="True">
25+
<local:CustomTextAnnotation X1="1.6" X2="2.4" Y1="17.8" Y2="20.3" HorizontalTextAlignment="Center"
26+
VerticalTextAlignment="Center" CanDrag="True" CanResize="True" x:Name="annotation">
2627
<local:CustomTextAnnotation.Content>
2728
<StackPanel Orientation="Horizontal">
2829
<Path Data="M16.710899,36.727C20.7409,39.759457 25.747499,41.558827 31.1693,41.558827 36.588501,
29-
41.558827 41.596401,39.759457 45.627602,36.727 55.046902,37.911882 62.335999,
30-
45.946764 62.335999,55.688923L62.335999,64 0,64 0,55.688923C0,45.946764,7.2904,37.911882,
31-
16.710899,36.727z M31.169201,0C40.807137,0 48.622002,7.8164558 48.622002,
32-
17.455803 48.622002,27.095258 40.807137,34.909003 31.169201,34.909003 21.528767,
33-
34.909003 13.715,27.095258 13.715,17.455803 13.715,7.8164558 21.528767,0 31.169201,0z"
34-
Stretch="Uniform" Fill="#606060" Height="50" Width="50"
35-
RenderTransformOrigin="0.5,0.5"/>
36-
<Button Content="Click Me" Width="145" Height="50" Click="Button_Click"/>
30+
41.558827 41.596401,39.759457 45.627602,36.727 55.046902,37.911882 62.335999,
31+
45.946764 62.335999,55.688923L62.335999,64 0,64 0,55.688923C0,45.946764,7.2904,37.911882,
32+
16.710899,36.727z M31.169201,0C40.807137,0 48.622002,7.8164558 48.622002,
33+
17.455803 48.622002,27.095258 40.807137,34.909003 31.169201,34.909003 21.528767,
34+
34.909003 13.715,27.095258 13.715,17.455803 13.715,7.8164558 21.528767,0 31.169201,0z"
35+
Stretch="Uniform" Fill="#606060" Height="49" Width="49"/>
36+
<TextBox Text="Employee:Jack Profit:16%" x:Name="textBox" Height="49" BorderBrush="Transparent"
37+
TextWrapping="Wrap" FontSize="15" HorizontalContentAlignment="Center"
38+
VerticalContentAlignment="Center" Foreground="Black"
39+
Background="Transparent" Width="105" />
3740
</StackPanel>
3841
</local:CustomTextAnnotation.Content>
3942
</local:CustomTextAnnotation>

Custom_Annotation/MainWindow.xaml.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ public MainWindow()
1414
{
1515
InitializeComponent();
1616
}
17-
18-
private void Button_Click(object sender, RoutedEventArgs e)
19-
{
20-
// Can perform any action required
21-
}
2217
}
2318

2419
public class CustomTextAnnotation : RectangleAnnotation

Custom_Annotation/ViewModel.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ public ViewModel()
1414
{
1515
Collection = new ObservableCollection<Model>();
1616

17-
Collection.Add(new Model() { XValue = "2009", YValue = 15 });
18-
Collection.Add(new Model() { XValue = "2010", YValue = 20 });
19-
Collection.Add(new Model() { XValue = "2011", YValue = 16 });
20-
Collection.Add(new Model() { XValue = "2012", YValue = 25 });
21-
Collection.Add(new Model() { XValue = "2013", YValue = 22 });
17+
Collection.Add(new Model() { XValue = "David", YValue = 15 });
18+
Collection.Add(new Model() { XValue = "Steve", YValue = 20 });
19+
Collection.Add(new Model() { XValue = "Jack", YValue = 16 });
20+
Collection.Add(new Model() { XValue = "Roger", YValue = 25 });
21+
Collection.Add(new Model() { XValue = "John", YValue = 22 });
2222
}
2323
}
2424

README.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,20 @@ public class CustomTextAnnotation : RectangleAnnotation
4444
</chart:SfChart.SecondaryAxis>
4545
4646
<chart:SfChart.Annotations>
47-
<local:CustomTextAnnotation HorizontalTextAlignment="Stretch" VerticalTextAlignment="Stretch" X1="1.6" X2="1.6" Y1="18" Y2="20" Fill="White" IsHitTestVisible="False" CanDrag="True" CanResize="True">
47+
<local:CustomTextAnnotation X1="1.6" X2="2.4" Y1="17.8" Y2="20.3" HorizontalTextAlignment="Center"
48+
VerticalTextAlignment="Center" CanDrag="True" CanResize="True" x:Name="annotation">
4849
<local:CustomTextAnnotation.Content>
4950
<StackPanel Orientation="Horizontal">
5051
<Path Data="M16.710899,36.727C20.7409,39.759457 25.747499,41.558827 31.1693,41.558827 36.588501,
51-
41.558827 41.596401,39.759457 45.627602,36.727 55.046902,37.911882 62.335999,
52-
45.946764 62.335999,55.688923L62.335999,64 0,64 0,55.688923C0,45.946764,7.2904,37.911882,
53-
16.710899,36.727z M31.169201,0C40.807137,0 48.622002,7.8164558 48.622002,
54-
17.455803 48.622002,27.095258 40.807137,34.909003 31.169201,34.909003 21.528767,
55-
34.909003 13.715,27.095258 13.715,17.455803 13.715,7.8164558 21.528767,0 31.169201,0z"
56-
Stretch="Uniform" Fill="#606060" Height="50" Width="50"
57-
RenderTransformOrigin="0.5,0.5"/>
58-
<Button Content="Click Me" Width="145" Height="50" Click="Button_Click"/>
52+
41.558827 41.596401,39.759457 45.627602,36.727 55.046902,37.911882 62.335999,
53+
45.946764 62.335999,55.688923L62.335999,64 0,64 0,55.688923C0,45.946764,7.2904,37.911882,
54+
16.710899,36.727z M31.169201,0C40.807137,0 48.622002,7.8164558 48.622002,
55+
17.455803 48.622002,27.095258 40.807137,34.909003 31.169201,34.909003 21.528767,
56+
34.909003 13.715,27.095258 13.715,17.455803 13.715,7.8164558 21.528767,0 31.169201,0z"
57+
Stretch="Uniform" Fill="#606060" Height="49" Width="49"/>
58+
<TextBox Text="Employee:Jack Profit:16%" x:Name="textBox" Height="49" BorderBrush="Transparent"
59+
TextWrapping="Wrap" FontSize="15" HorizontalContentAlignment="Center"
60+
VerticalContentAlignment="Center" Foreground="Black" Background="Transparent" Width="105" />
5961
</StackPanel>
6062
</local:CustomTextAnnotation.Content>
6163
</local:CustomTextAnnotation>
@@ -67,4 +69,4 @@ public class CustomTextAnnotation : RectangleAnnotation
6769

6870
## Output:
6971

70-
![Customized Rectangle Annotation with button](https://user-images.githubusercontent.com/102642528/211318119-488d4bda-402e-450e-ac06-b32592c28313.png)
72+
![Customized Rectangle Annotation with button](https://user-images.githubusercontent.com/102642528/212282757-e057007f-7bc2-46b7-832f-712dc69bbf20.png)

0 commit comments

Comments
 (0)