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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:42:30+00:00 2026-06-07T10:42:30+00:00

Maybe title is confusing you, but the problem is concretely here : I have

  • 0

Maybe title is confusing you, but the problem is concretely here : I have XAML file which there is ControlTemplate for MyType (inherits from ContentControl). And in that Template i set its DataContext like this :

DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}"

And when i want to get DataContext from MyType it shows null for first time. After clicking on it ( it is rectangle in window ) it changes to object what i need. I searched all things, all events what i am doing in LeftButtonDown there is no ApplyTemplate(),UpdateLayout() methods. Even i call these methods it doesn’t help. What need to do ? P.S this DataContext is Parent of this item, i can send is a parameter but there must be other solution

this is part of XAML which Template located:

<Style TargetType="{x:Type s:Connector}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type s:Connector}">
                <Grid Name="grid" DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}">
                    <Border BorderBrush="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, 
                        Path=BorderBrush}" x:Name="border" BorderThickness="2" Background="Transparent">        
                        <Image Source="/DiagramDesigner;component/Resources/1337238611_port.png"/>
                    </Border>
                    <Rectangle Fill="Transparent" Margin="-2"/>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

And this is where i want to get DataContext:

public DesignerItem ParentDesignerItem // 
    {
        get
        {

            if (parentDesignerItem == null)
            {

                parentDesignerItem = this.DataContext as DesignerItem;
               // if (parentDesignerItem==null) parentDesignerItem = (this.Template.FindName("grid", this) as Grid).DataContext as DesignerItem;
            }

            return parentDesignerItem;
        }
        set
        {

            parentDesignerItem = value;
        }
    }

I must say that this Style is in XAML which Style of the DesignerItem also.

  • 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-07T10:42:32+00:00Added an answer on June 7, 2026 at 10:42 am

    The problem is in my algorithm P.S i restore some information from SQL, and add 2 times more Connectors with null parameters and when i want to access it gives me these null objects.

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

Sidebar

Related Questions

Title may be confusing, but here's explanation with code. Based on some conditions, I
Maybe my title is not the best but here is what I really want.I
Maybe a confusing title, what I'm after is a class, which only has certain
Ok the title maybe a little confusing. I have a database with the table
Maybe there is a better way of describing my problem... Here is an example
Maybe not the best title I can think of but my problem is this:
Title sums it up. URL isn't an EKEvent property but figured maybe there's some
maybe I'm just misunderstanding Javascript's regular expression functionality but here goes... I have an
Ok, maybe the title is a little confusing, but what I am trying to
The title may be bit confusing but here is what I am facing I

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.