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 8531837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:34:39+00:00 2026-06-11T09:34:39+00:00

I’m getting exception: ‘{0}’ is not a Visual or Visual3D. The only question I

  • 0

I’m getting exception:

‘{0}’ is not a Visual or Visual3D.

The only question I found that similar: WPF: System.ArgumentException => {"'{0}' is not a Visual or Visual3D."}

I’m just building “pretty” grid. No need to handle double-clicks. It’s just side-effect when user double-clicks by mistake – this exception throws.

XAML looks like this:

<DataGrid
  ItemsSource="{Binding Source={StaticResource TrucksSource}}"
  CanUserReorderColumns="False" 
  CanUserResizeColumns="True" 
  CanUserResizeRows="False" 
  AutoGenerateColumns="False" 
  BorderThickness="0" 
  CanUserAddRows="False" 
  RowBackground="{StaticResource GrayBackgroundGradientBrush}"
  RowHeight="20" Focusable="False" RowHeaderWidth="0">
  <DataGrid.Columns>
      <DataGridTemplateColumn Header="Select" Width="40" CanUserSort="True" SortMemberPath="IsSelected">
          <DataGridTemplateColumn.CellTemplate>
              <DataTemplate>
                  <CheckBox
                      IsChecked="{Binding IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                      HorizontalAlignment="Center"
                      VerticalAlignment="Center" />
              </DataTemplate>
          </DataGridTemplateColumn.CellTemplate>
      </DataGridTemplateColumn>
      <DataGridTemplateColumn Header="Team" Width="42" CanUserSort="True" SortMemberPath="TeamDispatcherCaptionShort">
          <DataGridTemplateColumn.CellTemplate>
              <DataTemplate>
                  <Border
                  Margin="-2,-1">
                      <TextBlock ToolTip="{Binding TeamDispatcherCaptionLong}" 
                      Foreground="#414141" FontFamily="Arial" FontSize="12"
                      Text="{Binding TeamDispatcherCaptionShort}" 
                      HorizontalAlignment="Center" VerticalAlignment="Center" />
                  </Border>
              </DataTemplate>
          </DataGridTemplateColumn.CellTemplate>
      </DataGridTemplateColumn>

I get exception whenever user double-clicks. First column is checkbox. When it’s single-click-ed it works correct. When I click in any area around checkbox – exception.

How do I fix it? There is no code behind, it’s MVVM project

EDIT:

Ok, I went ahead and tried to repro this on small project. I already figured issue but want to know your take on this.. And I need to award this bounty 🙂

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Window.Resources>
        <ResourceDictionary>
            <CollectionViewSource x:Key="WidgetsSource" Source="{Binding Widgets}" />
        </ResourceDictionary>
    </Window.Resources>
    <Grid>
        <DataGrid
            ItemsSource="{Binding Source={StaticResource WidgetsSource}}"
            CanUserReorderColumns="False" 
            CanUserResizeColumns="True" 
            CanUserResizeRows="False" 
            AutoGenerateColumns="False" 
            BorderThickness="0" 
            CanUserAddRows="False" 
            VerticalGridLinesBrush="#00000000" 
            HorizontalGridLinesBrush="Gray" 
            RowBackground="LightGray"
            RowHeight="20" Focusable="False" RowHeaderWidth="0" SelectionUnit="Cell">
            <DataGrid.Columns>
                <DataGridTemplateColumn Header="Prop1" Width="50" CanUserSort="True" SortMemberPath="Prop1">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Border>
                                <TextBlock>
                                    <Run Text="{Binding NestWidg.Prop1}" />
                                </TextBlock>
                            </Border>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn Header="Prop2" Width="50" CanUserSort="True" SortMemberPath="Prop1">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Border>
                                <TextBlock Text="{Binding Prop1}" />
                            </Border>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>                
            </DataGrid.Columns>
        </DataGrid>
    </Grid>
</Window>

VM:

namespace WpfApplication1
{
    using System.Collections.ObjectModel;

    public class MainWindowVM
    {
        public ObservableCollection<Widget> Widgets { get; set; }

        public MainWindowVM()
        {
            this.Widgets = new ObservableCollection<Widget>();

            this.Widgets.Clear();
            this.Widgets.Add(new Widget("a", "b") { NestWidg = new NestWidget { Prop1 = "Nest" } });
        }
    }

    public class Widget
    {
        public Widget(string p1, string p2)
        {
            Prop1 = p1;
            Prop2 = p2;
        }

        public string Prop1 { get; private set; }

        public string Prop2 { get; private set; }

        public NestWidget NestWidg { get; set; }
    }

    public class NestWidget
    {
        public string Prop1 { get; set; }
    }
}

Code behind:

namespace WpfApplication1
{
    using System.Windows;

    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            this.InitializeComponent();
            this.DataContext = new MainWindowVM();
        }
    }
}
  • 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-06-11T09:34:40+00:00Added an answer on June 11, 2026 at 9:34 am

    Yes. Your sample project throws error now. That’s because you’ve binding with Run. In your first post, you were missing it, so that’s why I couldn’t reproduce it.

    It really seems that it’s quite old bug and many users have had it. Knowing microsoft, it wont be fixed anytime soon. (The bug has been part of WPF since beginning I guess).
    Your best bet is to be clever.

    Bind only objects that are Visuals. < Run > is not Visual.

    Youll have to make custom TextBlock that will generate correct Runs based on the DataContext without using binding. You need to declare new depedency property which will be part of TextBlock and hook yourself into UIPropertyChanged method, there you will generate Runs().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
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
I am doing a simple coin flipping experiment for class that involves flipping a

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.