dependencyproperty in a radWindow

2 posts, 0 answers
  1. Michel
    Michel avatar
    4 posts
    Member since:
    May 2008

    Posted 07 Jun 2011 Link to this post

    Hi,

    I have a problem with dependencyproperty in a RadWindow. It doesn't work if I bind my window on another element, this is my code : :

    My RadWindow XAML :
    <telerik:RadWindow x:Class="Env.Nc.App.Views.MyRadWindow"
            Header="MyRadWindow" Height="300" Width="300"
                DataContext="{Binding RelativeSource={RelativeSource Self}}">
        <Grid>
            <TextBlock Text="{Binding testDp}" />
        </Grid>
    </telerik:RadWindow>

    My RadWindow code behind:
    using System;
    using System.Windows;
      
    namespace Env.Nc.App.Views
    {
        /// <summary>
        /// Interaction logic for MyRadWindow.xaml
        /// </summary>
        public partial class MyRadWindow
        {
            public String testDp
            {
                get { return (String)GetValue(testDpProperty); }
                set { SetValue(testDpProperty, value); }
            }
      
            // Using a DependencyProperty as the backing store for testDp.  This enables animation, styling, binding, etc...
            public static readonly DependencyProperty testDpProperty =
                DependencyProperty.Register("testDp", typeof(String), typeof(MyRadWindow), new PropertyMetadata(null));
      
            public MyRadWindow()
            {
                InitializeComponent();
            }
        }
    }

    My MainPage XAML:
    <TextBlock x:Name="ttt" Text="My text"></TextBlock>
      
    <views:MyRadWindow x:Name="MyWindow" testDp="{Binding ElementName=ttt, Path=Text}"></views:MyRadWindow>

    I want to see "My text" in my RadWindow and I see nothing. Can anybody help?

    Thanks.
  2. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 08 Jun 2011 Link to this post

    Hi Michel,

     The RadWindow shouldn't be placed inside the layout - it only can be used as a root tag in XAML. One of the reasons it shouldn't be used this way is that it is moved out from this initial place as soon as it is shown and this breaks the Bindings and changes the children of the panel it was used into. What I would suggest you is to set this binding where you are showing the Window.

    Hope this information is helpful.

    Regards,
    Miroslav Nedyalkov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
Back to Top