次のようなカスタム XAML ユーザー コントロールがあります。
<UserControl x:Class="CheckPoint.Modules.Beach.Beach_Shape"
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="300" d:DesignWidth="300">
<Grid>
<Polygon Name="Shape"></Polygon>
</Grid>
</UserControl>
xaml で XamlWrite.Save でシリアル化し、XamlReader.Load で再読み込みします。
XmlReader reader = XmlReader.Create(new StringReader(xml));
UserControl uc=(UserControl)XamlReader.Load(reader);
myGrid.Children.Add(uc);
「uc」は myGrid で正しく視覚化されますが、「uc」オブジェクトは論理的に正しくありません。これは、たとえば、xaml にあるにもかかわらず、背景、ストローク、またはポイントが設定されていないなど、Shape 要素が正しく読み込まれていないためです。
私はそれをリロードしようとします
Shape=myGrid.Findname("Shape");
しかし、それも機能しません。
それで、私の間違いはどこですか?