Я пытаюсь перетащить файл в текстовое поле, чтобы задать содержимое текстового поля с путем к файлу (второй DataTemplate).
Поэтому я добавил событие DragOver в свой textBox. Но я получаю исключение Null.
Я перепробовал много других событий и получил ту же ошибку. В первом dataTemplate события работают нормально.
Это может быть потому, что мое текстовое поле находится во вложенном списке. Но я не уверен.
Есть идеи?
<ListBox ItemsSource="{Binding Model.Attributes, Mode=TwoWay}" HorizontalContentAlignment="Stretch" VerticalAlignment="Stretch" Background="{x:Null}" BorderBrush="{x:Null}" Margin="0" BorderThickness="0" VerticalContentAlignment="Stretch" PreviewKeyDown="ListBox_PreviewKeyDown">
<ListBox.Resources>
<DataTemplate DataType="{x:Type local:TransformModel}">
<Expander Header="Transform" VerticalAlignment="Top" d:LayoutOverrides="Width" FontSize="10.667" HorizontalAlignment="Stretch" IsExpanded="{Binding DataContext.Model.TransformIsExpanded, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}">
<StackPanel HorizontalAlignment="Stretch">
<Grid HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="14"/>
<ColumnDefinition Width="0.333*"/>
<ColumnDefinition Width="14"/>
<ColumnDefinition Width="0.333*"/>
<ColumnDefinition Width="14"/>
<ColumnDefinition Width="0.333*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="0.215*"/>
<RowDefinition Height="0.785*"/>
</Grid.RowDefinitions>
<TextBlock Margin="4,0" TextWrapping="Wrap" Text="Position" d:LayoutOverrides="Width, Height" Grid.ColumnSpan="6" FontSize="10.667"/>
<TextBlock TextWrapping="Wrap" Text="X" Grid.Row="1" VerticalAlignment="Top" Margin="4,0,0,0" d:LayoutOverrides="Width"/>
<TextBox Grid.Column="1" Grid.Row="1" TextWrapping="Wrap" Text="{Binding Position.X, Mode=TwoWay}" VerticalAlignment="Top" FontSize="8" Margin="0,0,-0.001,0" d:LayoutOverrides="Width" GotFocus="TextGotFocus" PreviewMouseLeftButtonDown="SelectivelyIgnoreMouseButton" />
<TextBlock TextWrapping="Wrap" Text="Y" Grid.Row="1" VerticalAlignment="Top" Margin="3.998,0,4.562,0" Grid.Column="2" d:LayoutOverrides="Width"/>
<TextBox Grid.Column="3" Grid.Row="1" TextWrapping="Wrap" Text="{Binding Position.Y, Mode=TwoWay}" VerticalAlignment="Top" FontSize="8" Margin="0" GotFocus="TextGotFocus" PreviewMouseLeftButtonDown="SelectivelyIgnoreMouseButton"/>
<TextBlock TextWrapping="Wrap" Text="Z" Grid.Row="1" VerticalAlignment="Top" Margin="3.999,0,4.344,0" Grid.Column="4" d:LayoutOverrides="Width"/>
<TextBox Grid.Column="5" Grid.Row="1" TextWrapping="Wrap" Text="{Binding Position.Z, Mode=TwoWay}" VerticalAlignment="Top" FontSize="8" Margin="0,0,4,0" GotFocus="TextGotFocus" PreviewMouseLeftButtonDown="SelectivelyIgnoreMouseButton"/>
</Grid>
<Grid HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="14"/>
<ColumnDefinition Width="0.333*"/>
<ColumnDefinition Width="14"/>
<ColumnDefinition Width="0.333*"/>
<ColumnDefinition Width="14"/>
<ColumnDefinition Width="0.333*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="0.215*"/>
<RowDefinition Height="0.785*"/>
</Grid.RowDefinitions>
<TextBlock Margin="4,0" TextWrapping="Wrap" Text="Size" d:LayoutOverrides="Width, Height" Grid.ColumnSpan="6" FontSize="10.667"/>
<TextBlock TextWrapping="Wrap" Text="X" Grid.Row="1" VerticalAlignment="Top" Margin="4,0,0,0" d:LayoutOverrides="Width"/>
<TextBox Grid.Column="1" Grid.Row="1" TextWrapping="Wrap" Text="{Binding Size.X, Mode=TwoWay}" VerticalAlignment="Top" FontSize="8" Margin="0,0,-0.001,0" d:LayoutOverrides="Width" GotFocus="TextGotFocus" PreviewMouseLeftButtonDown="SelectivelyIgnoreMouseButton"/>
<TextBlock TextWrapping="Wrap" Text="Y" Grid.Row="1" VerticalAlignment="Top" Margin="3.998,0,4.562,0" Grid.Column="2" d:LayoutOverrides="Width"/>
<TextBox Grid.Column="3" Grid.Row="1" TextWrapping="Wrap" Text="{Binding Size.Y, Mode=TwoWay}" VerticalAlignment="Top" FontSize="8" Margin="0" GotFocus="TextGotFocus" PreviewMouseLeftButtonDown="SelectivelyIgnoreMouseButton"/>
<TextBlock TextWrapping="Wrap" Text="Z" Grid.Row="1" VerticalAlignment="Top" Margin="3.999,0,4.344,0" Grid.Column="4" d:LayoutOverrides="Width"/>
<TextBox Grid.Column="5" Grid.Row="1" TextWrapping="Wrap" Text="{Binding Size.Z, Mode=TwoWay}" VerticalAlignment="Top" FontSize="8" Margin="0,0,4,0" GotFocus="TextGotFocus" PreviewMouseLeftButtonDown="SelectivelyIgnoreMouseButton"/>
</Grid>
<Separator Height="1" Margin="5,2,5,0"/>
</StackPanel>
</Expander>
</DataTemplate>
<DataTemplate DataType="{x:Type local:UnknownModel}">
<Expander Header="Miscellaneous" VerticalAlignment="Top" d:LayoutOverrides="Width" FontSize="10.667" HorizontalAlignment="Stretch" IsExpanded="{Binding DataContext.Model.TransformIsExpanded, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}">
<StackPanel HorizontalAlignment="Stretch">
<ListBox Grid.Row="1" VerticalAlignment="Top" ItemsSource="{Binding Attributs}" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Background="{x:Null}" BorderBrush="{x:Null}" Margin="0" BorderThickness="0">
<ListBox.Resources>
<DataTemplate DataType="{x:Type local:PropertiesAssetsModel}">
<Grid d:DesignWidth="682.4" Margin="0,0,0,4" d:DesignHeight="144">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.163*"/>
<ColumnDefinition Width="0.837*"/>
</Grid.ColumnDefinitions>
<TextBlock TextWrapping="Wrap" VerticalAlignment="Center" d:LayoutOverrides="Width" Text="Assets" Margin="0,0,-0.003,0"/>
<TextBox Grid.Column="1" Grid.Row="1" TextWrapping="Wrap" Text="{Binding Value, Mode=TwoWay}" VerticalAlignment="Top" FontSize="8" Margin="0,0,-0.001,0" d:LayoutOverrides="Width" AllowDrop="True" DragOver="AssetPathDragOvers"/>
</Grid>
</DataTemplate>
</ListBox.Resources>
</ListBox>
<Separator Height="1" Margin="5,2,5,0"/>
</StackPanel>
</Expander>
</DataTemplate>
</ListBox.Resources>
</ListBox>