Home › Forums › WPF controls › Other WPF controls › Xceed PropertyGrid work with System.Windows.Media.PointCollection
-
AuthorPosts
-
#43857 |
Hi,
I have a problem.
I using property grid to set Collection of points, but program give me InvalidOperationException: collection has been changed…
What am I doing wrong?Thank for answer.
Sniped code:
[TypeConverter(typeof(PointCollectionConverter))]
public PointCollection Points
{
get
{
return ((Polyline)xamlDraw.DRAW_OBJECT).Points;
}
set
{
((Polyline)xamlDraw.DRAW_OBJECT).Points = value;
}
}Hi,
Could you give me more details regarding the exception( sequence of activities, sample project,..) so that I could have a closer look.
I wrote small sample.
Everything property works perfectly, but property with PointCollection generate exception while save 🙁Sorry for my English
Thanks for help
Xaml:
<Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:WpfApplication1" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" mc:Ignorable="d" Title="MainWindow" Height="350" Width="600"> <Grid> <xctk:PropertyGrid x:Name="workplace_property" ShowSearchBox="False" Background="WhiteSmoke" UpdateTextBoxSourceOnEnterKey="True" ShowAdvancedOptions="True" SnapsToDevicePixels="True" IsMiscCategoryLabelHidden="True" SelectedObject="{Binding}" HorizontalAlignment="Right" Width="251"/> <Canvas Name="myCanvas" Margin="0"> </Canvas> </Grid> </Window>
cs:
using System; using System.Windows; using System.Windows.Media; using System.Windows.Shapes; using Xceed.Wpf.Toolkit.PropertyGrid.Attributes; namespace WpfApplication1 { public partial class MainWindow : Window { public Polyline drawobj; public MainWindow() { InitializeComponent(); drawobj = new Polyline(); drawobj.Points = new PointCollection() { new Point(10, 20), new Point(40, 20), new Point(150, 150) }; drawobj.StrokeThickness = 2; drawobj.Stroke = new SolidColorBrush(Colors.Black); myCanvas.Children.Add(drawobj); workplace_property.SelectedObject = new polyline_property(drawobj); } } public class polyline_property { private Polyline drawobj; public polyline_property(Polyline obj) { drawobj = obj; } public PointCollection Points { get { return drawobj.Points; } set { drawobj.Points = value; } } public Color Color { get { return ((SolidColorBrush)drawobj.Stroke).Color; } set { ((SolidColorBrush)drawobj.Stroke).Color = value; } } public Double StrokeThickness { get { return drawobj.StrokeThickness; } set { drawobj.StrokeThickness = value; } } public DoubleCollection StrokeDashArray { get { return drawobj.StrokeDashArray; } set { drawobj.StrokeDashArray = value; } } public PenLineCap StrokeDashCap { get { return drawobj.StrokeDashCap; } set { drawobj.StrokeDashCap = value; } } public Double StrokeDashOffset { get { return drawobj.StrokeDashOffset; } set { drawobj.StrokeDashOffset = value; } } } }
-
AuthorPosts
- You must be logged in to reply to this topic.