Telerik Forums
UI for WPF Forum
3 answers
112 views
Hi Guys!

I am fairly new into Telerik business, so please apologize if this isnt the way to report a possible bug.

My recent project is a simulation software for thermal power plants. In a canvas the user can drag&drop
various powergrid objects and connect them to each other.

The user can enter math formulas using public properties of any object on the canvas. And here comes
radExpressionEditor into the game. In this project I am using ILGenerator to dynamicaly add Properties
at runtime. Unfortunately radExpressionEditor doesnt support multiple Item objects.

So much for a little background info. Now for the bug.....

I have a object with the following signature:

    public class DynamicFields : INotifyPropertyChanged
    {

        public event PropertyChangedEventHandler PropertyChanged;

        private int _Test;
        public int Test
        {
            get { return _Test; }
            set { _Test = value; PropertyChangedHandler("Test"); }
        }

        public DynamicFields() { }

        public void PropertyChangedHandler(string propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        // BUG: RadExpressionEditor sets a Handle on this.PropertyChanged, but doesnt have any Targetdelegate.
        // Lets remove it here as a workaround!
        public void RemoveLastPropertyChangedHandler()
        {
            Delegate RemoveDelegate = this.PropertyChanged.GetInvocationList().Last();
            if (RemoveDelegate != null)
            {
                this.PropertyChanged -= (RemoveDelegate as PropertyChangedEventHandler);
            }
        }


Some other place in my code I do something like this:

            //Window with ExpressionEditor that will be shown as a dialog
            Window_ExpressionEditor ee = new Window_ExpressionEditor();

            //FormelEditor is an instance of ExpressionEditor
            ee.FormelEditor.Item = Device.dynamicFields;

            //As soon the Item Property is set to my Dynamicobject, radExpressionEditor will subscribe to
            //the PropertyChanged event but without any target method to call.
            //So then ever I change the Value of a property the PropertyChangedHandler raises an exception.

            //Workaround is to delete last entry of the GetInvocationList()
            DynamicFields df = this.Device.dynamicFields;
            df.RemoveLastPropertyChangedHandler();


This behaviour also occurs if I use a "normal" class without expanding the properties at runtime.
Right now my workaround runs fine, but would be nice to get this bug verified.

Oh and please implement radExpressionEditor.Items for multiple objects use ;-)

Thank you and my best regards, Martin
Stefan Dobrev
Telerik team
 answered on 14 Dec 2011
4 answers
430 views
How would you implement a hotkey for the Approve RadButton in the following code snippet?

          <telerik:RadButton Name="btApproveReport"  Click="btApproveReport_Click"  Margin="10,0,10,0" Width="Auto" HorizontalContentAlignment="Center" MaxHeight="30" VerticalContentAlignment="Center" > 
            <telerik:RadButton.Content> 
              <StackPanel Orientation="Horizontal" Margin="4 0"
                <TextBlock Text="Approve"   Foreground="DarkGreen" FontSize="12" /> 
                <Image Source="pack://application:,,,/Resources/CheckMark.png" Margin="5 0 0 0" Height="16" Width="16" /> 
              </StackPanel> 
            </telerik:RadButton.Content> 
          </telerik:RadButton> 

Petar Mladenov
Telerik team
 answered on 13 Dec 2011
0 answers
214 views
I have a combo box with multiple combobox items.  (The example is implemented using MVVM)

Each combo box item contains
1. DatePicker for StartDate
2. DatePicker for EndDate
3. OK button.
4. TextBlock

When the combo box is expanded and
1. When I click on the DatePicker control, the combo box collapses.  I was hoping that the DatePicker control would show me the calendar and I could select the date, instead of collapsing the combobox.
(Note: The above behavior is only for RadComboBox and not the default ComboBox)

2. When I click on the "OK" button, I calculate the Text that has to be displayed and I am expecting the combobox to collapse. (I have Command set up for button to handle the click event). But the combobox does not collapse

What I would like is
1.  Not let the combobox collapse when I click on the DatePicker control to select a date
2. When I click on the "OK" button, the combobox should collapse (just like when an item is selected inside combobox)

Note:  I am using MVVM, so I don't have scope to use event handlers.

Thanks.
Gautam
Top achievements
Rank 1
 asked on 13 Dec 2011
3 answers
56 views
Hello,

I'm trying to add an event handler for the RowDetailsVisibilityChangingEvent, but I get a compiler error.

Shouldn't this be possible:

Tb.AddHandler(

 

GridViewDataControl.RowDetailsVisibilityChangingEvent, new RoutedEventHandler(GridView_VisibilityChangingEvent));
The doc says it's part of the GridViewDataControl class.

Best regards
Oliver

 

Stephan
Top achievements
Rank 1
 answered on 13 Dec 2011
2 answers
109 views
Hi,

How can I add a marked zone in a programmatically way? I tried to look in the chart area object within the radchart but I couldn't find it.
I'm working with WPF.

Cheers
Goncalo
Top achievements
Rank 1
 answered on 13 Dec 2011
6 answers
701 views

 

Hi,

I have a main application and when the user click on a button, I create a dialog to display some informations. When a display this dialog, I restore his persistence and whe the user close this dialog, I save his persistence. After 2 or 3 attempts of displaying this dialog, my main application throw me an exception.

Environment:
VS2008
DotNet: 3.5
Telerik: 2011.3.1116.35

Here is my main application call:

private void btnPhone_Click(object sender, RoutedEventArgs e)

{

ReferringInfos dialog = new ReferringInfos(mDataSource, mCurrentVisit.ReferringPhysician, mCurrentVisit.ReferringPhones, true);

dialog.ShowDialog();

}

Here is my ReferringInfos class and xaml:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Windows;

using System.Windows.Controls;

using System.Windows.Data;

using System.Windows.Documents;

using System.Windows.Input;

using System.Windows.Media;

using System.Windows.Media.Imaging;

using System.Windows.Navigation;

using System.Windows.Shapes;

using com.ChristieGrp.Localisation;

using com.christiegrp.Neuron.Client;

using Telerik.Windows.Controls;

namespace com.christiegrp.Neuron.ClientApplication

{

/// <summary>

/// Interaction logic for ReferringInfos.xaml

/// </summary>

public partial class ReferringInfos : RadWindow

{

#region Constructors.

static ReferringInfos()

{

StyleManager.ApplicationTheme = new Office_BlueTheme();

LocalizationManager.Manager = new CustomLocalizationManager();

}

public ReferringInfos(NeuronDataSource pDataSource, string pReferringName, ShortPhoneNumber[] pPhoneList, Boolean pPersistence)

{

InitializeComponent();

mDataSource = pDataSource;

mPersistence = pPersistence;

this.ReferringName = pReferringName;

mPhoneNumbers = new List<PhoneNumber>();

fillPhoneNumbers(pPhoneList);

radGridView.ItemsSource = mPhoneNumbers;

Header = mDataSource.BuildFormName(LocGeneral.GetControlText("ReferringInfos"));

}

#endregion

#region Dependency properties.

public static readonly DependencyProperty ReferringNameProperty = DependencyProperty.Register("ReferringName", typeof(string), typeof(ReferringInfos));

#endregion

#region Public properties.

public string ReferringName

{

get

{

return (string)GetValue(ReferringNameProperty);

}

set

{

SetValue(ReferringNameProperty, value);

}

}

#endregion

#region Private methods.

private void fillPhoneNumbers(ShortPhoneNumber[] pPhoneList)

{

foreach (ShortPhoneNumber item in pPhoneList)

{

PhoneNumber phone = new PhoneNumber();

phone.Number = item.PhoneNumber;

phone.TypeCode = item.TypeCode;

mPhoneNumbers.Add(phone);

}

}

#endregion

#region Private events handler.

/// <summary>

/// Change dialog resources.

/// </summary>

/// <param name="sender"></param>

/// <param name="e"></param>

private void ReplaceLanguageResources(object sender, EventArgs e)

{

Localisation.SetUILanguage(this, "ReferringInfos", mDataSource);

}

/// <summary>

/// Dialog is closing.

/// </summary>

/// <param name="sender"></param>

/// <param name="e"></param>

private void RadWindow_PreviewClosed(object sender, WindowPreviewClosedEventArgs e)

{

if (mPersistence)

{

string errMsg;

PersistenceStorage.Persist(PersistenceStorage.PersistenceAction.Save, out errMsg);

}

}

/// <summary>

/// Dialog is loaded.

/// </summary>

/// <param name="sender"></param>

/// <param name="e"></param>

private void RadWindow_Loaded(object sender, RoutedEventArgs e)

{

if (mPersistence)

{

string errMsg;

PersistenceStorage.Persist(PersistenceStorage.PersistenceAction.Load, out errMsg);

}

}

/// <summary>

/// Close request.

/// </summary>

/// <param name="sender"></param>

/// <param name="e"></param>

private void btnClose_Click(object sender, RoutedEventArgs e)

{

Close();

}

#endregion

#region Private fields.

private NeuronDataSource mDataSource;

private Boolean mPersistence;

private List<PhoneNumber> mPhoneNumbers;

#endregion

}

/// <summary>

/// Class to hold a list of phone numbers.

/// </summary>

public class PhoneNumber

{

public string Number { get; set; }

public string TypeCode { get; set; }

}

}

 

<telerik:RadWindow x:Class="com.christiegrp.Neuron.ClientApplication.ReferringInfos"

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"

Height="300" Width="450" SizeToContent="False" Name="Me"

WindowStartupLocation="CenterScreen" PreviewClosed="RadWindow_PreviewClosed" Loaded="RadWindow_Loaded" ResizeMode="NoResize"

telerik:PersistenceManager.StorageId="ReferringInfos">

<telerik:RadWindow.IconTemplate>

<DataTemplate>

<Image Source="Resources/Doctor_48x48.png" Height="24" Width="24" Stretch="Fill" Margin="0 0 3 0" />

</DataTemplate>

</telerik:RadWindow.IconTemplate>

<telerik:RadWindow.Resources>

<ResourceDictionary>

<ResourceDictionary.MergedDictionaries>

<ResourceDictionary Source="ReferringInfos-Fr-Res.xaml"/>

<ResourceDictionary Source="/Telerik.Windows.Controls.Navigation;component/Themes/GenericOfficeBlack.xaml"/>

</ResourceDictionary.MergedDictionaries>

</ResourceDictionary>

</telerik:RadWindow.Resources>

<Grid Margin="5">

<Grid.ColumnDefinitions>

<ColumnDefinition Width="*"/>

<ColumnDefinition Width="Auto"/>

</Grid.ColumnDefinitions>

<Grid.RowDefinitions>

<RowDefinition Height="Auto"/>

<RowDefinition Height="*"/>

<RowDefinition Height="Auto"/>

</Grid.RowDefinitions>

<!-- The following element is used to trigger an event allowing to replace the language resources before they are used. -->

<TextBlock Initialized="ReplaceLanguageResources"/>

<StackPanel Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="0" Orientation="Horizontal">

<Image Source="Resources/Doctor_48x48.png" Height="32" Width="32" Stretch="Fill" />

<Label Margin="5" FontSize="16" VerticalAlignment="Center" Content="{Binding ElementName=Me, Path=ReferringName}"/>

</StackPanel>

<telerik:RadGridView Name="radGridView" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" ShowGroupPanel="False" IsSynchronizedWithCurrentItem="True" IsReadOnly="True" SelectionMode="Single" RowIndicatorVisibility="Collapsed" AutoGenerateColumns="False" SelectionUnit="FullRow">

<telerik:RadGridView.Columns>

<telerik:GridViewDataColumn IsGroupable="False" IsFilterable="False" DataMemberBinding="{Binding Path=Number}" Header="{StaticResource Number}" />

<telerik:GridViewDataColumn IsGroupable="False" IsFilterable="False" DataMemberBinding="{Binding Path=TypeCode}" Header="{StaticResource Type}" />

</telerik:RadGridView.Columns>

</telerik:RadGridView>

<telerik:RadButton Grid.Column="1" Grid.Row="2" Margin="0 5 0 0" Name="btnClose" Click="btnClose_Click">

<StackPanel Orientation="Horizontal">

<Image Margin="5 0 0 0" Source="Resources/Close_32x32.png" Height="24" Width="24" />

<TextBlock Margin="5" VerticalAlignment="Center" Text="{StaticResource Close}"/>

</StackPanel>

</telerik:RadButton>

</Grid>

</telerik:RadWindow>

Here is my log:
2011-12-01 23:41:29,660;[5852];ERROR;MNGUI016;System.Windows.Markup.XamlParseException: La valeur « ReferringInfos » ne peut pas être attribuée à la propriété « StorageId » de l’objet « com.christiegrp.Neuron.ClientApplication.ReferringInfos ». Un élément avec la même clé a déjà été ajouté.  Erreur à l’objet « Me » dans le fichier de balisage « ClientHelper;component/referringinfos.xaml » ligne 7 position 5. ---> System.ArgumentException: Un élément avec la même clé a déjà été ajouté.
   à System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   à System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   à System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
   à Telerik.Windows.PersistenceFramework.ObjectStorage.AddItemToStorage(String key, DependencyObject item)
   à Telerik.Windows.Persistence.PersistenceManager.OnStorageIdChanged(DependencyObject d, DependencyPropertyChangedEventArgs args)
   à System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   à System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   à System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
   à System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, OperationType operationType)
   à System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, OperationType operationType, Boolean isInternal)
   à System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
   à System.Windows.Markup.BamlRecordReader.SetDependencyValueCore(DependencyObject dependencyObject, DependencyProperty dependencyProperty, Object value)
   à System.Windows.Markup.BamlRecordReader.SetDependencyValue(DependencyObject dependencyObject, DependencyProperty dependencyProperty, Object value)
   à System.Windows.Markup.BamlRecordReader.SetPropertyValue(Object o, PropertyDefinition propertyDefinition, Object value)
   à System.Windows.Markup.BamlRecordReader.ReadPropertyRecordBase(String attribValue, Int16 attributeId, Int16 converterTypeId)
   --- Fin de la trace de la pile d'exception interne ---
   à System.Windows.Markup.XamlParseException.ThrowException(String message, Exception innerException, Int32 lineNumber, Int32 linePosition, Uri baseUri, XamlObjectIds currentXamlObjectIds, XamlObjectIds contextXamlObjectIds, Type objectType)
   à System.Windows.Markup.XamlParseException.ThrowException(ParserContext parserContext, Int32 lineNumber, Int32 linePosition, String message, Exception innerException)
   à System.Windows.Markup.BamlRecordReader.ThrowExceptionWithLine(String message, Exception innerException)
   à System.Windows.Markup.BamlRecordReader.ReadPropertyRecordBase(String attribValue, Int16 attributeId, Int16 converterTypeId)
   à System.Windows.Markup.BamlRecordReader.ReadPropertyConverterRecord(BamlPropertyWithConverterRecord bamlPropertyRecord)
   à System.Windows.Markup.BamlRecordReader.ReadRecord(BamlRecord bamlRecord)
   à System.Windows.Markup.BamlRecordReader.Read(Boolean singleRecord)
   à System.Windows.Markup.TreeBuilderBamlTranslator.ParseFragment()
   à System.Windows.Markup.TreeBuilder.Parse()
   à System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
   à System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
   à com.christiegrp.Neuron.ClientApplication.ReferringInfos.InitializeComponent() dans d:\Developpement\GestX.Courant\RisGC\Client\ClientHelper\ReferringInfos.xaml:ligne 1
   à com.christiegrp.Neuron.ClientApplication.ReferringInfos..ctor(NeuronDataSource pDataSource, String pReferringName, ShortPhoneNumber[] pPhoneList, Boolean pPersistence) dans D:\Developpement\GestX.Courant\RisGC\Client\ClientHelper\ReferringInfos.xaml.cs:ligne 36
   à com.christiegrp.Neuron.ClientApplication.DictationForm.btnPhone_Click(Object sender, RoutedEventArgs e)
   à System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   à System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   à System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   à System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
   à System.Windows.Controls.Primitives.ButtonBase.OnClick()
   à System.Windows.Controls.Button.OnClick()
   à Telerik.Windows.Controls.RadButton.OnClick()
   à System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
   à System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e)
   à System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   à System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   à System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   à System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   à System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
   à System.Windows.UIElement.CrackMouseButtonEventAndReRaiseEvent(DependencyObject sender, MouseButtonEventArgs e)
   à System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
   à System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   à System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   à System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   à System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   à System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   à System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   à System.Windows.Input.InputManager.ProcessStagingArea()
   à System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   à System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   à System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   à System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   à System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   à MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   à MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   à System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
   à System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
   à System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
   à System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
   à System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
   à MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   à System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   à System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
   à System.Windows.Forms.NativeWindow.WndProc(Message& m)
   à System.Windows.Forms.Integration.WindowsFormsHost.ActivateWindowListener.WndProc(Message& m)
   à System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   à MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   à System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   à System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   à System.Windows.Window.ShowHelper(Object booleanBox)
   à System.Windows.Window.Show()
   à System.Windows.Window.ShowDialog()
   à Telerik.Windows.Controls.InternalWindow.WindowWithNoChromeWindowHost.Open(Boolean isModal)
   à Telerik.Windows.Controls.WindowBase.ShowWindow(Boolean isModal)
   à Telerik.Windows.Controls.RadWindow.ShowDialog()
   à com.christiegrp.Neuron.ClientApplication.DictationModuleWPF.StartFunction()
   à com.christiegrp.Neuron.ClientApplication.MainGui.listView_ItemActivate(Object sender, EventArgs e) dans D:\Developpement\GestX.Courant\RisGC\Client\Neuron\MainGui.cs:ligne 1031

 

 

 

Tina Stancheva
Telerik team
 answered on 13 Dec 2011
1 answer
71 views
In my RadChart (2011 - Q3), I have two Y axis. I would like to have a custom grid line drawn against my second Y Axis, which is named 'CdSimStdDev'. Is this possible to do in XAML. I don't see a way to specify the name of a Y axis to associate with the custom line.
Thank you.
Randy Minder
Top achievements
Rank 1
 answered on 13 Dec 2011
11 answers
153 views
Hi

I would like to control the visibility of the backstage component via my viewmodel through databinding, see below.

IsBackstageOpen="{Binding BackstageIsOpen}"

Although I get no errors, the ribbon is not responding to changes in my property value. (I am notifying the property change).

Any ideas?
ITC
Top achievements
Rank 1
 answered on 13 Dec 2011
1 answer
176 views
Hi!

I am looking for a Telerik text box control that does validation of the data when the "Enter" key is hit.  The validation should be similar to the Telerik data grid.  On the data grid the "Enter" key forces a validation without losing focus.  Is there a telerik textbox control available that I can take advantage of?  if you can show me an example that shows how to implement this.

For example:  If the textbox is bound to a number and user enters a letter and presses "Enter" then the border of the textbox get highlighted to red without losing focus.

Thanks,

Sonia
Boby
Telerik team
 answered on 13 Dec 2011
1 answer
194 views
Hello,

I try to display a list of UserControls in a RadTabControl and to use a UserControl property (name) to display tab header and dropdown items.

According to this post (http://www.telerik.com/community/forums/wpf/tabcontrol/radtabitem-headertemplate-not-responding-to-binding-to-usercontrol-object-properties.aspx), I succeded in displaying Tab Header with UserControl "Name" property.
To do this, I use a RelativeSource :

Text

 

 

="{Binding DataContext.Name, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=telerik:RadTabItem}}"

 


I have used your TabControl-Q1.zip sample project (from post above) where I have modified MainWindow.xaml.cs file to create a list of UserControls :

this

 

 

.radtabVariableControlsContainer.ItemsSource =

 

 

 

Enumerable.Range(0, 10).Select(x => new UserControl() { Name = "name" + x });

 


My RadTabControl and related template definition is this one :
<Grid>
  
        <Grid.Resources>
  
            <DataTemplate x:Key="ContentAreaTabHeaderTemplate">
                <TextBlock Text="{Binding DataContext.Name, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=telerik:RadTabItem}}" FontFamily="Arial" FontSize="13.333" />
            </DataTemplate>
  
        </Grid.Resources>
  
        <telerik:RadTabControl x:Name="radtabVariableControlsContainer"                               
                               BorderBrush="{x:Null}"
                               SelectedItemRemoveBehaviour="SelectPrevious"
                               ItemTemplate="{StaticResource ContentAreaTabHeaderTemplate}"
                               DropDownDisplayMode="Visible"
                               ItemDropDownContentTemplate="{StaticResource ContentAreaTabHeaderTemplate}"/>
  
    </Grid>

It so work find for ItemTemplate to display Tabs Header, but I don't succeed in displaying UserControls names in DropDown.
The "name" property never appear in dropdown...

Many thanks for your help !

Yann
Petar Mladenov
Telerik team
 answered on 13 Dec 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?