私の現在の実装では、境界があると思ったコレクションにデータが含まれていても、フォームに何も表示されません(デバッグでチェックインしました)。
ここにいくつかのコードがあります:
public event PropertyChangedEventHandler PropertyChanged;
PointCollection imagePoints;
public PointCollection ImagePoints
{
get
{
return this.imagePoints;
}
set
{
if (this.imagePoints != value)
{
this.imagePoints = value;
if (this.PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs("ImagePoints"));
}
}
}
}
および対応するxaml:
<Polygon x:Name="imagePolygon" Points="{Binding ImagePoints}" Stretch="Fill" Fill="Black" Opacity="0.8" />
今、私はコードを書くことによってすべてのバインディングを行いました。この例では、問題なく機能しますが、私の場合、ポイントはポリゴンに表示されません。
知恵の真珠はありますか?
編集:これが完全なxamlコードです
<Window
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" mc:Ignorable="d" x:Class="WpfApplication2.HistogramWindow"
Title="HistogramWindow" Height="436" Width="604">
<Grid>
<TabControl HorizontalAlignment="Left" Height="406" VerticalAlignment="Top" Width="596" >
<TabItem x:Name="imageTab" Header="Full Image" Height="23" VerticalAlignment="Top">
<Border BorderBrush="Black" BorderThickness="1" Margin="10">
<Polygon x:Name="imagePolygon" Points="{Binding ImagePoints}" Stretch="Fill" Fill="Black" Opacity="0.8" />
</Border>
</TabItem>
<TabItem x:Name="boneTab" Header="Bone">
<Border BorderBrush="Black" BorderThickness="1" Margin="10">
<Border.BindingGroup>
<BindingGroup/>
</Border.BindingGroup>
<Polygon x:Name="bonePolygon" Points="{Binding BonePoints}" Stretch="Fill" Fill="Black" Opacity="0.8" >
</Polygon>
</Border>
</TabItem>
<TabItem x:Name="fatTab" Header="Fat" HorizontalAlignment="Left" Height="20" VerticalAlignment="Top" Width="57">
<Border BorderBrush="Black" BorderThickness="1" Margin="10">
<Polygon x:Name="fatPolygon" Points="{Binding FatPoints}" Stretch="Fill" Fill="Black" Opacity="0.8" />
</Border>
</TabItem>
</TabControl>
</Grid>
編集:設定ファイルを変更した後、出力ウィンドウに次のように表示されます。
System.Windows.Data Information: 41 : BindingExpression path error: 'ImagePoints' property not found for 'object' because data item is null. This could happen because the data provider has not produced any data yet. BindingExpression:Path=ImagePoints; DataItem=null; target element is 'Polygon' (Name='imagePolygon'); target property is 'Points' (type 'PointCollection')
System.Windows.Data Information: 20 : BindingExpression cannot retrieve value due to missing information. BindingExpression:Path=ImagePoints; DataItem=null; target element is 'Polygon' (Name='imagePolygon'); target property is 'Points' (type 'PointCollection')
System.Windows.Data Information: 21 : BindingExpression cannot retrieve value from null data item. This could happen when binding is detached or when binding to a Nullable type that has no value. BindingExpression:Path=ImagePoints; DataItem=null; target element is 'Polygon' (Name='imagePolygon'); target property is 'Points' (type 'PointCollection')
System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=ImagePoints; DataItem=null; target element is 'Polygon' (Name='imagePolygon'); target property is 'Points' (type 'PointCollection')