Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7408045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:50:25+00:00 2026-05-29T05:50:25+00:00

I’m trying to drop a file into a textbox in order to set the

  • 0

I’m trying to drop a file into a textbox in order to set the content of the textbox with the path of the file (second DataTemplate).
So I added the event DragOver on my textBox. But I get an Null reference exception.
I tried many other events and got the same error. In the first dataTemplate, events are just working fine.

This may be because my textbox is in a nested list. But i am not sure.

Any idea ?

    <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>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:50:25+00:00Added an answer on May 29, 2026 at 5:50 am

    Thanks,

    Nested data templates are not working properly with .NET 4.0

    You can read more about this bug :
    Official bug report

    My workaround :

    Create my own data template selector :

    public class TemplateSelector : DataTemplateSelector
    {
        public DataTemplate UnknownTemplate { get; set; }
    
        public override DataTemplate SelectTemplate(object item,
                   DependencyObject container)
        {
            if (item is PropertiesUnkownModel)
            {
                return UnknownTemplate;
            }
            return UnknownTemplate;
        }
    }
    

    Template selector in xaml :

    <view:TemplateSelector x:Key="templateSelector" UnknownTemplate="{StaticResource PropertiesUnkownModel}"/>
    

    and how I use it :

    <ListBox Grid.Row="1" VerticalAlignment="Top" ItemsSource="{Binding Attributs}" ItemTemplateSelector="{DynamicResource templateSelector}"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to render a haml file in a javascript response like so:
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.