バインディングの問題の解決策を見つけるのに苦労しています。
ユーザーがオブジェクトを選択できる別のウィンドウを呼び出すためのボタンがあるユーザーコントロールがあります。このオブジェクトを選択すると、ウィンドウが閉じ、ユーザー コントロール内のオブジェクトのプロパティが選択に従って更新されます。このオブジェクトのプロパティはユーザー コントロール内のコントロールにバインドされていますが、オブジェクト内のプロパティを更新しても、コントロール内の値は更新されません (意味があることを願っています)。
これはスリム化されたコードビハインドです:
public partial class DrawingInsertControl : UserControl
{
private MailAttachment Attachment { get; set; }
public DrawingInsertControl(MailAttachment pAttachment)
{
Attachment = pAttachment;
InitializeComponent();
this.DataContext = Attachment;
}
private void btnViewRegister_Click(object sender, RoutedEventArgs e)
{
DocumentRegisterWindow win = new DocumentRegisterWindow();
win.ShowDialog();
if (win.SelectedDrawing != null)
{
Attachment.DwgNo = win.SelectedDrawing.DwgNo;
Attachment.DwgTitle = win.SelectedDrawing.Title;
}
}
}
そしてxaml:
<UserControl x:Class="DrawingInsertControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="310" d:DesignWidth="800" >
<Border BorderBrush="Black" BorderThickness="2" Margin="10">
<Grid>
...
<TextBox Grid.Column="1" Name="txtDocNo" Text="{Binding DwgNo}" />
最後に、別のモジュールにある添付オブジェクト:
Public Class MailAttachment
Public Property DwgNo As String
End Class
名前空間や、関連性がないと思われるその他のものは省略しました。助けてくれてありがとう。