# C1.WPF.VTreeHelper.GetParentOfType

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_WPF_VTreeHelper_GetParentOfType_" data-uid="C1.WPF.VTreeHelper.GetParentOfType*">GetParentOfType Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_WPF_VTreeHelper_GetParentOfType_" data-uid="C1.WPF.VTreeHelper.GetParentOfType*"></a>
<h4 id="C1_WPF_VTreeHelper_GetParentOfType_System_Windows_DependencyObject_System_Type_" data-uid="C1.WPF.VTreeHelper.GetParentOfType(System.Windows.DependencyObject,System.Type)">GetParentOfType(DependencyObject, Type)</h4>
<div class="markdown level1 summary"><p>Returns a <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.dependencyobject">DependencyObject</a> value that represents the parent
of the visual object of the specified type. Method looks up the visual tree until
the desired parent element is found or parent element is null.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public static DependencyObject GetParentOfType(DependencyObject reference, Type type)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Shared Function GetParentOfType(reference As DependencyObject, type As Type) As DependencyObject</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.dependencyobject">DependencyObject</a></td>
      <td><span class="parametername">reference</span></td>
      <td><p>The visual whose parent is returned.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.type">Type</a></td>
      <td><span class="parametername">type</span></td>
      <td><p>The <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.type">Type</a> of the parent element to search for.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.dependencyobject">DependencyObject</a></td>
      <td><p>The parent of the visual.</p>
</td>
    </tr>
  </tbody>
</table>


<a id="C1_WPF_VTreeHelper_GetParentOfType_" data-uid="C1.WPF.VTreeHelper.GetParentOfType*"></a>
<h4 id="C1_WPF_VTreeHelper_GetParentOfType_System_Windows_DependencyObject_System_Type_System_Windows_DependencyObject_" data-uid="C1.WPF.VTreeHelper.GetParentOfType(System.Windows.DependencyObject,System.Type,System.Windows.DependencyObject)">GetParentOfType(DependencyObject, Type, DependencyObject)</h4>
<div class="markdown level1 summary"><p>Returns a <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.dependencyobject">DependencyObject</a> value that represents the parent
of the visual object of the specified type. Method looks up the visual tree until
the desired parent element is found or parent element is equal to the specified endObject.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public static DependencyObject GetParentOfType(DependencyObject reference, Type type, DependencyObject endObject)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Shared Function GetParentOfType(reference As DependencyObject, type As Type, endObject As DependencyObject) As DependencyObject</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.dependencyobject">DependencyObject</a></td>
      <td><span class="parametername">reference</span></td>
      <td><p>The visual whose parent is returned.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.type">Type</a></td>
      <td><span class="parametername">type</span></td>
      <td><p>The <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.type">Type</a> of the parent element to search for.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.dependencyobject">DependencyObject</a></td>
      <td><span class="parametername">endObject</span></td>
      <td><p>The visual representing the end point of search.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.dependencyobject">DependencyObject</a></td>
      <td><p>The parent of the visual.</p>
</td>
    </tr>
  </tbody>
</table>


<a id="C1_WPF_VTreeHelper_GetParentOfType_" data-uid="C1.WPF.VTreeHelper.GetParentOfType*"></a>
<h4 id="C1_WPF_VTreeHelper_GetParentOfType_System_Windows_DependencyObject_System_Type_System_Boolean_" data-uid="C1.WPF.VTreeHelper.GetParentOfType(System.Windows.DependencyObject,System.Type,System.Boolean)">GetParentOfType(DependencyObject, Type, bool)</h4>
<div class="markdown level1 summary"><p>Returns a <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.dependencyobject">DependencyObject</a> value that represents the parent
of the visual object of the specified type. Method looks up the visual tree until
the desired parent element is found or parent element is null.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public static DependencyObject GetParentOfType(DependencyObject reference, Type type, bool lookOutsideVisualTree)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Shared Function GetParentOfType(reference As DependencyObject, type As Type, lookOutsideVisualTree As Boolean) As DependencyObject</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.dependencyobject">DependencyObject</a></td>
      <td><span class="parametername">reference</span></td>
      <td><p>The visual whose parent is returned.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.type">Type</a></td>
      <td><span class="parametername">type</span></td>
      <td><p>The <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.type">Type</a> of the parent element to search for.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></td>
      <td><span class="parametername">lookOutsideVisualTree</span></td>
      <td><p>Specifies whether the search should go on outside the VisualTree.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.dependencyobject">DependencyObject</a></td>
      <td><p>The parent of the visual.</p>
</td>
    </tr>
  </tbody>
</table>


<a id="C1_WPF_VTreeHelper_GetParentOfType_" data-uid="C1.WPF.VTreeHelper.GetParentOfType*"></a>
<h4 id="C1_WPF_VTreeHelper_GetParentOfType_System_Windows_DependencyObject_System_Type_System_Windows_DependencyObject_System_Boolean_" data-uid="C1.WPF.VTreeHelper.GetParentOfType(System.Windows.DependencyObject,System.Type,System.Windows.DependencyObject,System.Boolean)">GetParentOfType(DependencyObject, Type, DependencyObject, bool)</h4>
<div class="markdown level1 summary"><p>Returns a <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.dependencyobject">DependencyObject</a> value that represents the parent
of the visual object of the specified type. Method looks up the visual tree until
the desired parent element is found or parent element is equal to the specified endObject.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public static DependencyObject GetParentOfType(DependencyObject reference, Type type, DependencyObject endObject, bool lookOutsideVisualTree)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Shared Function GetParentOfType(reference As DependencyObject, type As Type, endObject As DependencyObject, lookOutsideVisualTree As Boolean) As DependencyObject</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.dependencyobject">DependencyObject</a></td>
      <td><span class="parametername">reference</span></td>
      <td><p>The visual whose parent is returned.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.type">Type</a></td>
      <td><span class="parametername">type</span></td>
      <td><p>The <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.type">Type</a> of the parent element to search for.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.dependencyobject">DependencyObject</a></td>
      <td><span class="parametername">endObject</span></td>
      <td><p>The visual representing the end point of search.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></td>
      <td><span class="parametername">lookOutsideVisualTree</span></td>
      <td><p>Specifies whether the search should go on outside the VisualTree.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.dependencyobject">DependencyObject</a></td>
      <td><p>The parent of the visual.</p>
</td>
    </tr>
  </tbody>
</table>
</div>
