Telerik Forums
UI for WPF Forum
1 answer
173 views
Hi

I have a small problem. When I validate a TextBoxes Value and than giving the User a visual feedback everything works prefectly fine.

When I do this with a RadComboBox, the only thing that works is the validation part. But I don't get any visual feedback. Here is the XAML part in my App.xaml

<Application x:Class="CDM.App" 
             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" 
             xmlns:telerikInput="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input" 
             > 
    <Application.Resources> 
    <Storyboard x:Key="FlashError"
            <ObjectAnimationUsingKeyFrames BeginTime="00:00:00"  
                                       Storyboard.TargetProperty="(UIElement.Visibility)"
                <DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{x:Static Visibility.Visible}"/> 
                <DiscreteObjectKeyFrame KeyTime="00:00:05" Value="{x:Static Visibility.Hidden}"/> 
            </ObjectAnimationUsingKeyFrames> 
        </Storyboard> 
    <Style x:Key="myErrorTemplate" TargetType="Control"
        <Setter Property="Validation.ErrorTemplate"
            <Setter.Value> 
                <ControlTemplate> 
                    <StackPanel Orientation="Vertical"
                        <Border BorderBrush="Red" BorderThickness="1"
                            <AdornedElementPlaceholder Name="mycontrol"
 
                                <Label Foreground="White" Background="Red"  
                                           Content="{Binding ElementName=mycontrol,  
                                                     Path=AdornedElement.(Validation.Errors)[0].ErrorContent}"> 
                                        <Label.Triggers> 
                                            <EventTrigger RoutedEvent="FrameworkElement.Loaded"
                                                <BeginStoryboard Storyboard="{StaticResource FlashError}" /> 
                                            </EventTrigger> 
                                        </Label.Triggers> 
                                    </Label> 
                            </AdornedElementPlaceholder> 
                        </Border> 
 
                        <!--<Label Foreground="White" Background="Red"  
                                           Content="{Binding ElementName=mycontrol,  
                                                     Path=AdornedElement.(Validation.Errors)[0].ErrorContent}"> 
                        </Label>--> 
                    </StackPanel> 
                </ControlTemplate> 
            </Setter.Value> 
        </Setter> 
        <Style.Triggers> 
 
            <Trigger Property="Validation.HasError" Value="true"
                <Setter Property="ToolTip"  
                            Value="{Binding  
                                    RelativeSource={x:Static RelativeSource.Self}, 
                                    Path=(Validation.Errors)[0].ErrorContent}" /> 
            </Trigger> 
        </Style.Triggers> 
    </Style> 
 
      <Style TargetType="TextBox" BasedOn="{StaticResource myErrorTemplate}" /> 
    <Style TargetType="CheckBox" BasedOn="{StaticResource myErrorTemplate}" /> 
        <Style TargetType="telerik:RadComboBox" BasedOn="{StaticResource myErrorTemplate}" /> 
    </Application.Resources> 
</Application> 
 

And here the the C# Part for Validation. Allthough I am convincied that the validation works. Tested it several times.

    public Platten() 
        { 
            this.preisReference.AssociationChanged += new CollectionChangeEventHandler(preisReference_AssociationChanged); 
 
            this.AddError("preis""Preiscode fehlt!"); 
        } 
 
        void preisReference_AssociationChanged(object sender, CollectionChangeEventArgs e) 
        { 
            if (e.Action == CollectionChangeAction.Remove) 
            { 
                OnPropertyChanging("preis"); 
            } 
            else 
            { 
                if (e.Action == CollectionChangeAction.Add) 
                { 
                    this.RemoveError("preis"); 
                } 
                OnPropertyChanged("preis"); 
            } 
        } 
        #region IDataErrorInfo Members 
        private Dictionary<stringstring> m_validationErrors = new Dictionary<stringstring>(); 
 
        private void AddError(string columnName, string msg) 
        { 
            if (!m_validationErrors.ContainsKey(columnName)) 
            { 
                m_validationErrors.Add(columnName, msg); 
            } 
        } 
 
        private void RemoveError(string columnName) 
        { 
            if (m_validationErrors.ContainsKey(columnName)) 
            { 
                m_validationErrors.Remove(columnName); 
            } 
        } 
 
        public bool HasErrors 
        { 
            get { return m_validationErrors.Count > 0; } 
        } 
 
        public string Error 
        { 
            get 
            { 
                if (m_validationErrors.Count > 0) 
                { 
                    return "Customer data is invalid"
                } 
                else 
                { 
                    return null
                } 
            } 
        } 
 
        public string this[string columnName] 
        { 
            get 
            { 
                if (m_validationErrors.ContainsKey(columnName)) 
                { 
                    return m_validationErrors[columnName]; 
                } 
                else return null
            } 
        } 
        #endregion 


Thanks for your help.






Hristo
Telerik team
 answered on 06 May 2010
2 answers
133 views
Hi,
I added items to a treeview programmatically(with two for loop) and set the tag property to a value for each of an Child item.  But there is a problem.

 

 

 

RadTreeViewItem rti;

 

 

for (int i = 0; i < ParentCount; i++)

 

{

 

  rti =

new RadTreeViewItem();

 

  rti.Header = Parent[i].Name;

 

 

  for (int j = 0; j < ChildCount; j++)

 

    {

    rti.Items.Add(Child[j].Name);

 

    rti.Tag = Child[j].Number);

 

   

}

  MyRadTreeView.Items.Add(rti); //MyRadTreeView is declared at XAML code.

}

I want to reach rti's Tag property from any of an event(Selected, SelectionChange...), but none of these events give me the Tag property's value. The Tag's value comes with null. 
How can I achieve this issue?

EMRE ANDIC
Top achievements
Rank 1
 answered on 06 May 2010
1 answer
137 views

I was wondering how you would allow the user to resize the width of the Outlook Bar at runtime.  I am playing with the trial version of the controls and I did not see the ability to resize the outlook bar width once it is on the screen.  Do you need to pair this control with another Telerik control to get this functionality?  I basically want to set an initial width and give the user the ability to resize.  Please let me know if you have an example.   

Thanks, 
Joel
Valentin.Stoychev
Telerik team
 answered on 06 May 2010
5 answers
72 views
Hi ..

does GridView control works with .net 3.0, I know the demo requires .net3.5 but can we use the conrol with application that uses .net 3.0 not 3.5

Thanks
Wisam
Milan
Telerik team
 answered on 06 May 2010
7 answers
459 views
Hi everyone. I have problems on expanding the root node of the treeview at start. I do not use data binding and I have about 4 hierarhical levels. In code at runtime I call the ExpandAll() for the level 0 nodes but they do not expand. If I expand the level 0 nodes afterwards in the UI I can see that all other levels below are expanded.

farhan iqbal
Top achievements
Rank 1
 answered on 06 May 2010
4 answers
239 views
Hello.
I'm using Q1 2010 for WPF.

I have this following simple sample:
<Window x:Class="sample.Window1" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:telNavigationControls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" 
    xmlns:telControlsControls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls" 
    xmlns:sample="clr-namespace:sample" 
    Title="Sample Window" Height="300" Width="300"
     
    <Window.Resources> 
 
        <Style x:Key="TelerikTabItemContainerStyle" TargetType="{x:Type telNavigationControls:RadTabItem}"
            <Setter Property="HeaderTemplate"
                <Setter.Value> 
                    <DataTemplate> 
                        <Button x:Name="closeButton" Content="Test Button" Height="25" sample:RoutedEventHelper.EnableRoutedClick="True"/> 
                    </DataTemplate> 
                </Setter.Value> 
            </Setter> 
        </Style> 
 
    </Window.Resources> 
     
    <Grid> 
        <telNavigationControls:RadTabControl x:Name="mainTabControl" ItemContainerStyle="{StaticResource TelerikTabItemContainerStyle}" > 
 
            <telNavigationControls:RadTabItem > 
                <telNavigationControls:RadTabItem.Content> 
                    <Button HorizontalAlignment="Center" VerticalAlignment="Center" Content="Test" IsDefault="True" /> 
                </telNavigationControls:RadTabItem.Content> 
            </telNavigationControls:RadTabItem> 
 
        </telNavigationControls:RadTabControl> 
    </Grid> 
</Window> 

As you can see, there is one RadTabControl with one RadTabItem. I've modified RadTabItem header through ItemContainerStyle. There is only one button in HeaderTemplate. I've used RoutedEventHandler class for allowing the button's click events to be catched.
Here is the code:
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Windows; 
using System.Windows.Controls; 
 
using Telerik.Windows; 
using Telerik.Windows.Controls; 
 
namespace sample 
    class RoutedEventHelper 
    { 
        // TAB CLOSE BUTTON EVENT 
        public static readonly RoutedEvent TabCloseButtonPressedEvent = EventManager.RegisterRoutedEvent( 
            "TabCloseButtonPressed", 
            RoutingStrategy.Bubble, 
            typeof(RoutedEventHandler), 
            typeof(RoutedEventHelper)); 
 
        // DEPENDENCY PROPERTY FOR TAB ITEM HEADER BUTTON 
        public static readonly DependencyProperty EnableRoutedClickProperty = DependencyProperty.RegisterAttached( 
           "EnableRoutedClick", 
           typeof(bool), 
           typeof(RoutedEventHelper), 
           new PropertyMetadata(OnEnableRoutedClickChanged)); 
 
        // Add an attached property 
        public static bool GetEnableRoutedClick(DependencyObject obj) 
        { 
            return (bool)obj.GetValue(EnableRoutedClickProperty); 
        } 
 
        public static void SetEnableRoutedClick(DependencyObject obj, bool value) 
        { 
            obj.SetValue(EnableRoutedClickProperty, value); 
        } 
 
        // TAB EVENT HANDLER 
        private static void OnEnableRoutedClickChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) 
        { 
            var button = sender as Button; 
 
            if (button != null) 
                button.Click += CloseButton_Click; 
        } 
 
        private static void CloseButton_Click(object sender, RoutedEventArgs e) 
        { 
            var button = sender as Button; 
            if (button == null) return; 
 
            button.RaiseEvent(new RoutedEventArgs(TabCloseButtonPressedEvent, button)); 
        } 
    } 
 

Everything works fine with one exception. If I put another Button as RadTabItem Content (as you can see in the above xaml example) and I set property of this button "IsDefault = true", the click events from the first button in RadTabItem header are not fired.
Is this behavior correct ?

I have also second question:
Imagine almost the same situation as in the previous example. I've RadTabItem with modified HeaderTemplate with one button in it. I've no buttons in the RadTabItem Content, so when I click on Button in my RadTabItem header, the click event is fired correctly. 
Let's continue. Now I've got for example two RadTabItems (with the same HeaderTemplate) in one RadTabControl. The first RadTabItem is selected, the second one not. And now here it comes. When I click on the button (button in RadTabItem header) in the RadTabItem which is NOT selected, the event is not fired, only this specified RadTabItem becomes selected. So the click events are fired only when the RadTabItem is Selected.

The following behavior would be best for me: When I click on the button in header of arbitrary RadTabItem (selected or not) the click event of the button will be fired but the selection of the RadTabItems will NOT changed.

Is this scenario possible ? Or it would be great if at least the event of the buttons will be fired no matter the RadTabItem is selected or not.

Thank you a lot.

Stefan.



Ivan
Telerik team
 answered on 06 May 2010
1 answer
224 views
I've a window with a listbox on the left half and a listview on the right half. The DataTemplate of the listview is set to a template which contains a listbox, so for every row of the listview a new listbox is created. Now I want to drag an item from the left half of the window into one of the nested listboxes on the right half. The problem is, that the nested listboxes aren't registered as drop target zones, although the AllowDrop-prop is set to true. If I set the AllowDrop-Property of the listview to true, the DropQuery-Event is raised, but the e.Options.Destination is always the listview, not the listbox inside it.

Any help is appreciated.

Thanks

Patrick


Tina Stancheva
Telerik team
 answered on 05 May 2010
1 answer
107 views
Hi,

In my application, I am showing a GridView with a Child Table.
As there a quite a lot of items in the GridView, I want the row height as low as possible.
When i set the row height in my grid, either by setting the RowStyle or by using a RowStyleSelector, my child table isn't shown anymore when i try to expand it.

Is there any other way of decreasing the rowheight of my GridView but still allow the Child Table to be shown?

Thanks,

Hans
Yordanka
Telerik team
 answered on 05 May 2010
2 answers
93 views
Hello!
Is there the possibility to have the NumericUpDown component having only values that are powers of 10.
Like 0.001; 0.01; 0.1; 1; 10; 100 etc 

Thank you!
Roxana C
RoxanaC
Top achievements
Rank 1
 answered on 05 May 2010
3 answers
166 views
Hello.

I have simple application. In this application is one RadTabControl with twor RadTabItems and in both are RadDockings with one RadPane in each. Here is the code:
<Grid> 
        <telNavigationControls:RadTabControl x:Name="mainTabControl" Grid.Row="0" HorizontalAlignment="Stretch" 
                VerticalAlignment="Stretch" DisplayMemberPath="Content" DropDownDisplayMode="Collapsed" ScrollMode="Viewport"  
                Background="#dde1ea" telControlsControls:StyleManager.Theme="Windows7" SnapsToDevicePixels="True" SelectedIndex="0"
 
            <!--FIRST TAB ITEM--> 
            <telNavigationControls:RadTabItem Header="Tab 1"
                <telNavigationControls:RadTabItem.Content> 
                    <telDockingControls:RadDocking HasDocumentHost="False"
                        <telDockingControls:RadSplitContainer > 
                            <telDockingControls:RadPaneGroup > 
                                <telDockingControls:RadPane Title="Tab1" Style="{StaticResource TelerikRadPaneStyle}"/> 
                            </telDockingControls:RadPaneGroup> 
                        </telDockingControls:RadSplitContainer> 
                    </telDockingControls:RadDocking> 
                </telNavigationControls:RadTabItem.Content> 
            </telNavigationControls:RadTabItem> 
 
            <!--SECOND TAB ITEM--> 
            <telNavigationControls:RadTabItem Header="Tab 2"
                <telNavigationControls:RadTabItem.Content > 
                    <telDockingControls:RadDocking HasDocumentHost="False"
                        <telDockingControls:RadSplitContainer > 
                            <telDockingControls:RadPaneGroup > 
                                <telDockingControls:RadPane Title="Tab2" Style="{StaticResource TelerikRadPaneStyle}"/> 
                            </telDockingControls:RadPaneGroup> 
                        </telDockingControls:RadSplitContainer> 
                    </telDockingControls:RadDocking> 
                </telNavigationControls:RadTabItem.Content> 
            </telNavigationControls:RadTabItem> 
        </telNavigationControls:RadTabControl> 
 
    </Grid> 

On each RadPane is applied simple Style, which changes also the TitleTemplate. Here is it:
 <Style x:Key="TelerikRadPaneStyle" TargetType="{x:Type telDockingControls:RadPane}"
            <Setter Property="CanUserPin" Value="False" /> 
            <Setter Property="CanFloat" Value="True" /> 
            <Setter Property="CanUserClose" Value="False" /> 
            <Setter Property="ContextMenuTemplate"
                <Setter.Value> 
                    <DataTemplate> 
                        <telNavigationControls:RadContextMenu Visibility="Collapsed" /> 
                    </DataTemplate> 
                </Setter.Value> 
            </Setter> 
            <Setter Property="TitleTemplate"
                <Setter.Value> 
                    <DataTemplate > 
                        <Grid > 
                            <Grid.ColumnDefinitions> 
                                <ColumnDefinition Width="Auto" /> 
                            </Grid.ColumnDefinitions> 
                            <Button Grid.Column="0" Width="100" Content="Test Button" HorizontalAlignment="Center"/> 
                        </Grid> 
                    </DataTemplate> 
                </Setter.Value> 
            </Setter> 
        </Style> 

And here is the problem. When I start my application, the first RadPane in first RadTabItem is with applied style, but when I select second RadTabItem, the RadPane in this item is withou applied style.

Can you please tell me where is the problem or what I'm doing wrong ?

Thank You.

Stefan.



Miroslav Nedyalkov
Telerik team
 answered on 05 May 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?