0

これが私がXAMLで持っているコードです:

        <!-- ItemsControl to print all the GDTs on the map as an overlay on tiles -->
        <ItemsControl ItemsSource="{Binding GDTs, Mode=OneWay}" Grid.ColumnSpan="3" Grid.RowSpan="3" Panel.ZIndex="7">
          <ItemsControl.ItemsPanel>
            <ItemsPanelTemplate>
              <Canvas ClipToBounds="True" SnapsToDevicePixels="true"/>
            </ItemsPanelTemplate>
          </ItemsControl.ItemsPanel>
          <ItemsControl.ItemContainerStyle>
            <Style TargetType="ContentPresenter">
              <Setter Property="Canvas.Left"  Value="{Binding DistanceToLeft}"/>
              <Setter Property="Canvas.Top"   Value="{Binding DistanceToTop}"/>
              <Setter Property="ContentTemplate">
                <Setter.Value>
                  <DataTemplate>
                    <Grid>
                      <userControls:CommIndicator CommConfig="eDt" DtAntennaMode="eDirectional" DtAzimuth="{Binding Yaw}"/>
                      <Image HorizontalAlignment="Center" VerticalAlignment="Center" Source="{Binding SourcePath}" Width="{Binding Width}"/>
                      <Rectangle Height="{Binding Height}" Width="{Binding Width}" Stroke="Orange" StrokeThickness="2"/>
                      <Ellipse Height="4" Width="4" Fill="Orange" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                    </Grid>
                  </DataTemplate>
                </Setter.Value>
              </Setter>
            </Style>
          </ItemsControl.ItemContainerStyle>
        </ItemsControl>

UserControl (CommIndicator) 内に追加したばかりのDtAzimuth="{Binding Yaw}"を除いて、そこにあるすべてのバインディングが機能しています。

そのバインディングで Snoop に表示されるエラーは次のとおりです。 :Path=Yaw; DataItem='CommIndicator' (Name=''); ターゲット要素は 'CommIndicator' (Name=''); ターゲット プロパティは 'DtAzimuth' (type 'Int32')"

ItemsControl "currentItem" でバインディングを強制的にチェックインする方法はありますか?

編集 1: これが私の UserControl の XAML です。

    <UserControl x:Class="UserControls.CommIndicator"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing"
             xmlns:userControls="clr-namespace:UserControls"
             DataContext="{Binding RelativeSource={RelativeSource Self}}"
             SnapsToDevicePixels="True">

  <UserControl.Resources>
    <ResourceDictionary>
      <userControls:CommConfigToVisibility x:Key="CommConfigToVisibility"/>
      <userControls:AntennaModeToAngle     x:Key="AntennaModeToAngle"/>
      <userControls:AntennaModeToColor     x:Key="AntennaModeToColor"/>
    </ResourceDictionary>
  </UserControl.Resources>

  <Grid Width="100" Height="100">
        <!-- Only use this for design reference -->
        <!--<Grid Width="70" Height="70" HorizontalAlignment="Center" VerticalAlignment="Center">
          <Ellipse Width="66" Height="66" Stroke="WhiteSmoke" StrokeThickness="3" HorizontalAlignment="Center" VerticalAlignment="Center"/>
          <Ellipse Width="66" Height="66" Fill="WhiteSmoke" StrokeThickness="3" HorizontalAlignment="Center" VerticalAlignment="Center" Opacity="0.30"/>
          <Ellipse Width="70" Height="70" Stroke="LimeGreen" StrokeThickness="3" HorizontalAlignment="Center" VerticalAlignment="Center"/>
          <Image HorizontalAlignment="Center" VerticalAlignment="Center" Source="/Resources/BlackShadowTopView.png" Width="40"/>
          <TextBlock Text="160" Margin="6" HorizontalAlignment="Center" TextAlignment="Center" Foreground="Black"/>
        </Grid>-->

        <!-- ADR Communication Circle Indicator --> 
        <Grid HorizontalAlignment="Center" VerticalAlignment="Center" Width="100" Height="100"
              Visibility="{Binding CommConfig, Converter={StaticResource CommConfigToVisibility}, ConverterParameter={x:Static userControls:CommType.eDataRelay}}">
          <Ellipse Width="100" Height="100" Stroke="Black" StrokeThickness="7"/>
          <ed:Arc Width="99" Height="99" Fill="SlateGray" StartAngle="0" EndAngle="360" ArcThickness="5"/>
          <ed:Arc Width="99" Height="99" Stretch="None" ArcThickness="6"
                Fill="{Binding DrAntennaMode, Converter={StaticResource AntennaModeToColor}}"
                StartAngle="{Binding DrAntennaMode, Converter={StaticResource AntennaModeToAngle}, ConverterParameter={x:Static userControls:AngleType.eStartAngle}}" 
                EndAngle="{Binding DrAntennaMode, Converter={StaticResource AntennaModeToAngle}, ConverterParameter={x:Static userControls:AngleType.eEndAngle}}"/>

          <Grid.LayoutTransform>
            <RotateTransform Angle="{Binding DrAzimuth}"/>
          </Grid.LayoutTransform>
        </Grid>

        <!-- ADT/GDT Communication Circle Indicator -->
        <Grid HorizontalAlignment="Center" VerticalAlignment="Center" Width="90" Height="90"
              Visibility="{Binding CommConfig, Converter={StaticResource CommConfigToVisibility}, ConverterParameter={x:Static userControls:CommType.eDataTransmitter}}">
          <Ellipse Width="88" Height="88" Stroke="Black" StrokeThickness="7"/>
          <ed:Arc Width="87" Height="87" Fill="SlateGray" StartAngle="0" EndAngle="360" ArcThickness="5"/>
          <ed:Arc Width="87" Height="87" Stretch="None" ArcThickness="6"
                Fill="{Binding DtAntennaMode, Converter={StaticResource AntennaModeToColor}}"
                StartAngle="{Binding DtAntennaMode, Converter={StaticResource AntennaModeToAngle}, ConverterParameter={x:Static userControls:AngleType.eStartAngle}}" 
                EndAngle="{Binding DtAntennaMode, Converter={StaticResource AntennaModeToAngle}, ConverterParameter={x:Static userControls:AngleType.eEndAngle}}"/>

          <Grid.LayoutTransform>
            <RotateTransform Angle="{Binding DtAzimuth}"/>
          </Grid.LayoutTransform>
        </Grid>
      </Grid>
    </UserControl>
4

1 に答える 1