あなたがその問題を解決したかどうかはわかりませんが、私は同じ問題に苦労し、解決策を思いつきました.
まず、以下のコードのように独自のカスタム マーカー シンボルを作成します。
public class TextBoxMarkerSymbol : MarkerSymbol
{
public static readonly DependencyProperty ContentTextProperty = DependencyProperty.Register("ContentText", typeof(string), typeof(TextBoxMarkerSymbol), new PropertyMetadata(OnTextChanged));
//private string contentText;
public string ContentText
{
get { return (string)GetValue(ContentTextProperty); }
set { SetValue(ContentTextProperty, value); }
}
private static void OnTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
}
public TextBoxMarkerSymbol(int width, int height)
{
string template = "<ControlTemplate " +
"xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>" +
"<Canvas>";
template += "<TextBox Name='txtText' Text='{Binding Symbol.ContentText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}' Height='" + height + "' Width='" + width + "' />";
template += " </Canvas>" +
"</ControlTemplate>";
System.IO.MemoryStream templateStream = new System.IO.MemoryStream(System.Text.UTF8Encoding.Default.GetBytes(template));
this.ControlTemplate = System.Windows.Markup.XamlReader.Load(templateStream) as ControlTemplate;
}
}
ここでの秘訣は、マーカー コントロールが視覚的ではないため、コントロールに直接アクセスできないことです。
そのため、コントロール プロパティの依存関係プロパティを定義する必要があるため、Symbol を使用してそれらをバインドできます。
次に、シンボルを以下のコードとして使用できます。
TextBoxMarkerSymbol mSymbol = new TextBoxMarkerSymbol(width, height);
mSymbol.OffsetX = width / 2;
mSymbol.OffsetY = height / 2;
mSymbol.ContentText = "test binding";
ごきげんよう。