This is a migrated thread and some comments may be shown as answers.

dependencyproperty in a radWindow

1 Answer 66 Views
Window
This is a migrated thread and some comments may be shown as answers.
Michel
Top achievements
Rank 1
Michel asked on 08 Jun 2011, 01:39 AM
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.

1 Answer, 1 is accepted

Sort by
0
Miroslav Nedyalkov
Telerik team
answered on 08 Jun 2011, 08:25 AM
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
Tags
Window
Asked by
Michel
Top achievements
Rank 1
Answers by
Miroslav Nedyalkov
Telerik team
Share this question
or