Note that there are some explanatory texts on larger screens.

plurals
  1. POwpf binding from child window
    primarykey
    data
    text
    <p>I'm learning XAML and I'm having a problem binding content of a control to a settings property from a child window.</p> <p>Here's a quick example I've made to make it more clear. Calling the child from the main window:</p> <pre class="lang-vb prettyprint-override"><code>Private Sub Button1_Click(sender As Object, e As RoutedEventArgs) Handles Button1.Click Dim OwndWindow As New WindowChild OwndWindow.Owner = Me OwndWindow.ShowDialog() End Sub </code></pre> <p>And this is the child:</p> <pre class="lang-xaml prettyprint-override"><code>&lt;Window x:Class="WindowChild" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:src="clr-namespace:WpfApplication2" Title="WindowChild" Height="300" Width="300"&gt; &lt;Window.Resources&gt; &lt;ObjectDataProvider x:Key="ObjDatPro" ObjectType="{x:Type src:TestSettings}"&gt;&lt;/ObjectDataProvider&gt; &lt;/Window.Resources&gt; &lt;Grid DataContext="{Binding Source={StaticResource ObjDatPro}}"&gt; &lt;CheckBox Content="CheckBox" Margin="0" HorizontalAlignment="Center" VerticalAlignment="Center" IsChecked="{Binding Default.BoolSetting, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/&gt; &lt;/Grid&gt; &lt;/Window&gt; </code></pre> <p>At this point Visual Studio is reporting an error: <em>The name "TestSettings" does not exist in the namespace "clr-namespace:WpfApplication2".</em> (Line 7, Column 49)</p> <p>I've tried changing this part to <code>WindowChild.TestSettings</code>, but then VS complains that nested types are not supported.</p> <p>Changing CLR namespace to <code>WpfApplication2.WindowChild</code> or even <code>WindowChild</code> doesn't do the trick, VS says: <em>Undefined CLR namespace. The 'clr-namespace' URI refers to a namespace 'WindowChild' that could not be found.</em></p> <p>What am I doing wrong here?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload