мои товарищи-программисты!
Я искал Inte rnet и не нашел решения. Вероятно, это связано с тем, что я новичок ie в WPF. Я пытаюсь достичь следующего:
CustomControl
, имеющий ArcSegment
, Size
которого привязан к размеру CustomControl
:
This should illustrate a wafer with dies (semiconductor industry)
So I understood that I need to use
in XAML in order to construct that 'circle with notch'
My problem is that I cannot bind the ArcSegment
element to CustomControl's Size
. ArcSegment
has Size
property and CustomControl
has ActualWidth
& ActualHeight
. I tried several approaches but neither of them worked for me.
Here is my class for CustomControl
:
public class WaferMap : Control
{
public static readonly DependencyProperty ActualSizeProperty = DependencyProperty.Register(
nameof(ActualSize), typeof(Size), typeof(WaferMap), new PropertyMetadata(default(Size)));
public Size ActualSize
{
get => (Size) this.GetValue(ActualSizeProperty);
set => this.SetValue(ActualSizeProperty, value);
}
public WaferMap()
{
var actualWidthPropertyDescriptor = DependencyPropertyDescriptor.FromProperty(ActualWidthProperty, typeof(WaferMap));
actualWidthPropertyDescriptor.AddValueChanged(this, OnActualWidthOrHeightChanged);
var actualHeightPropertyDescriptor = DependencyPropertyDescriptor.FromProperty(ActualHeightProperty, typeof(WaferMap));
actualHeightPropertyDescriptor.AddValueChanged(this, OnActualWidthOrHeightChanged);
}
private void OnActualWidthOrHeightChanged(object? sender, EventArgs e)
{
this.ActualSize = new Size(ActualWidth, ActualHeight);
}
static WaferMap()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(WaferMap), new FrameworkPropertyMetadata(typeof(WaferMap)));
}
}
And the XAML Style that I use for it: