Telerik Forums
UI for WPF Forum
5 answers
172 views
Hello Forum

I was following your Tutorial about "Styling a Cell" (http://www.telerik.com/help/wpf/gridview-styling-cell.html). My ViewModel implements INotifyDataErrorInfo and exposes Errors through it.

When i am hovering the mouse over the red triangle to see the error tool tip, i get the following Exception: 'xform' name cannot be found in the name scope of 'System.Windows.Controls.Grid'.

Do you have any suggestions?

Thanks,
Michael

Here is my Code:
...by the way: i have prepared a sample solution, but i can't attach it to the post.

MainWindow.xaml:

<Window x:Class="TelerikGridViewCellStyle.MainWindow"
        xmlns:telerikGridViewCellStyle="clr-namespace:TelerikGridViewCellStyle" mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="525" d:DataContext="{d:DesignInstance telerikGridViewCellStyle:ViewModel}">
    <Window.Resources>
        <Style TargetType="{x:Type telerik:GridViewCell}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type telerik:GridViewCell}">
                        <Grid>
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="SelectionStates">
                                    <VisualState x:Name="Unselected"/>
                                    <VisualState x:Name="Selected">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="Background_Selected">
                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Visibility>Visible</Visibility>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal"/>
                                    <VisualState x:Name="Current">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="Background_Current">
                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Visibility>Visible</Visibility>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="MouseOver">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="Background_Over">
                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Visibility>Visible</Visibility>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="EditingStates">
                                    <VisualState x:Name="Edited">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Margin" Storyboard.TargetName="PART_ContentPresenter">
                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Thickness>0</Thickness>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="VerticalAlignment" Storyboard.TargetName="PART_ContentPresenter">
                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <VerticalAlignment>Stretch</VerticalAlignment>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="PART_CellBorder">
                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <SolidColorBrush Color="White"/>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Display"/>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="DisabledStates">
                                    <VisualState x:Name="Enabled"/>
                                    <VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PART_CellBorder">
                                                <DiscreteDoubleKeyFrame KeyTime="0" Value="0.4"/>
                                            </DoubleAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PART_ContentPresenter">
                                                <DiscreteDoubleKeyFrame KeyTime="0" Value="0.7"/>
                                            </DoubleAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="Background_Disabled">
                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Visibility>Visible</Visibility>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="ValueStates">
                                    <VisualState x:Name="CellValid"/>
                                    <VisualState x:Name="CellInvalid">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="Background_Invalid">
                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Visibility>Visible</Visibility>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="InvalidUnfocused">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="Background_Invalid_Unfocused">
                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Visibility>Visible</Visibility>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Border x:Name="PART_CellBorder" BorderBrush="{TemplateBinding VerticalGridLinesBrush}" Background="{Binding Background, RelativeSource={RelativeSource TemplatedParent}}" Margin="1,0,0,0">
                                <Border.BorderThickness>
                                    <Binding ConverterParameter="Right" Path="VerticalGridLinesWidth" RelativeSource="{RelativeSource TemplatedParent}">
                                        <Binding.Converter>
                                            <telerik:GridLineWidthToThicknessConverter/>
                                        </Binding.Converter>
                                    </Binding>
                                </Border.BorderThickness>
                            </Border>
                            <Border x:Name="Background_Over" BorderBrush="#FFFFC92B" BorderThickness="1" Grid.ColumnSpan="2" Grid.Column="2" CornerRadius="1" Margin="1,1,2,2" Visibility="Collapsed">
                                <Border BorderBrush="White" BorderThickness="1">
                                    <Border.Background>
                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                            <GradientStop Color="#FFFFFBA3" Offset="1"/>
                                            <GradientStop Color="#FFFFFBDA" Offset="0"/>
                                        </LinearGradientBrush>
                                    </Border.Background>
                                </Border>
                            </Border>
                            <Border x:Name="Background_Selected" BorderBrush="#FFFFC92B" BorderThickness="1" Grid.ColumnSpan="2" Grid.Column="2" CornerRadius="1" Margin="1,1,2,2" Visibility="Collapsed">
                                <Border BorderBrush="White" BorderThickness="1">
                                    <Border.Background>
                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                            <GradientStop Color="#FFFCE79F" Offset="1"/>
                                            <GradientStop Color="#FFFDD3A8"/>
                                        </LinearGradientBrush>
                                    </Border.Background>
                                </Border>
                            </Border>
                            <Border x:Name="Background_Current" BorderBrush="#FF848484" BorderThickness="1" Grid.ColumnSpan="2" Grid.Column="2" CornerRadius="1" Margin="1,1,2,2" Visibility="Collapsed"/>
                            <Border x:Name="Background_Invalid" BorderBrush="#FFDB000C" BorderThickness="1" Background="White" Grid.ColumnSpan="2" Grid.Column="2" CornerRadius="1" Margin="1,1,2,2" Visibility="Collapsed">
                                <Border.ToolTip>
                                    <ToolTip x:Name="validationTooltip" Content="{TemplateBinding Errors}" Placement="Right">
                                        <ToolTip.Template>
                                            <ControlTemplate TargetType="{x:Type ToolTip}">
                                                <Grid x:Name="Root" Margin="5,0" Opacity="0" RenderTransformOrigin="0,0">
                                                    <Grid.RenderTransform>
                                                        <TranslateTransform X="-25"/>
                                                    </Grid.RenderTransform>
                                                    <VisualStateManager.VisualStateGroups>
                                                        <VisualStateGroup x:Name="OpenStates">
                                                            <VisualStateGroup.Transitions>
                                                                <VisualTransition From="{x:Null}" GeneratedDuration="0" GeneratedEasingFunction="{x:Null}" Storyboard="{x:Null}" To="{x:Null}"/>
                                                                <VisualTransition From="{x:Null}" GeneratedDuration="0:0:0.2" GeneratedEasingFunction="{x:Null}" To="Open">
                                                                    <Storyboard>
                                                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="X" Storyboard.TargetName="xform">
                                                                            <SplineDoubleKeyFrame KeyTime="0:0:0.2" Value="0"/>
                                                                        </DoubleAnimationUsingKeyFrames>
                                                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Root">
                                                                            <SplineDoubleKeyFrame KeyTime="0:0:0.2" Value="1"/>
                                                                        </DoubleAnimationUsingKeyFrames>
                                                                    </Storyboard>
                                                                </VisualTransition>
                                                            </VisualStateGroup.Transitions>
                                                            <VisualState x:Name="Closed">
                                                                <Storyboard>
                                                                    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Root">
                                                                        <SplineDoubleKeyFrame KeyTime="0" Value="0"/>
                                                                    </DoubleAnimationUsingKeyFrames>
                                                                </Storyboard>
                                                            </VisualState>
                                                            <VisualState x:Name="Open">
                                                                <Storyboard>
                                                                    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="X" Storyboard.TargetName="xform">
                                                                        <SplineDoubleKeyFrame KeyTime="0" Value="0"/>
                                                                    </DoubleAnimationUsingKeyFrames>
                                                                    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Root">
                                                                        <SplineDoubleKeyFrame KeyTime="0" Value="1"/>
                                                                    </DoubleAnimationUsingKeyFrames>
                                                                </Storyboard>
                                                            </VisualState>
                                                        </VisualStateGroup>
                                                    </VisualStateManager.VisualStateGroups>
                                                    <Border Background="#052A2E31" CornerRadius="5" Margin="4,4,-4,-4"/>
                                                    <Border Background="#152A2E31" CornerRadius="4" Margin="3,3,-3,-3"/>
                                                    <Border Background="#252A2E31" CornerRadius="3" Margin="2,2,-2,-2"/>
                                                    <Border Background="#352A2E31" CornerRadius="2" Margin="1,1,-1,-1"/>
                                                    <Border Background="#FFDC000C" CornerRadius="2"/>
                                                    <Border CornerRadius="2">
                                                        <ItemsControl>
                                                            <ItemsControl.ItemsPanel>
                                                                <ItemsPanelTemplate>
                                                                    <StackPanel IsItemsHost="True"/>
                                                                </ItemsPanelTemplate>
                                                            </ItemsControl.ItemsPanel>
                                                            <ItemsControl.ItemTemplate>
                                                                <DataTemplate>
                                                                    <TextBlock Foreground="White" MaxWidth="250" Margin="8,4" TextWrapping="Wrap" Text="{Binding}"/>
                                                                </DataTemplate>
                                                            </ItemsControl.ItemTemplate>
                                                        </ItemsControl>
                                                    </Border>
                                                </Grid>
                                            </ControlTemplate>
                                        </ToolTip.Template>
                                    </ToolTip>
                                </Border.ToolTip>
                                <Grid Background="Transparent" HorizontalAlignment="Right" Height="12" Margin="1,-4,-4,0" VerticalAlignment="Top" Width="12">
                                    <Path Data="M1,0L6,0A2,2,90,0,1,8,2L8,7z" Fill="#FFDB000C" Margin="1,3,0,0"/>
                                    <Path Data="M0,0L2,0 8,6 8,8" Fill="White" Margin="1,3,0,0"/>
                                </Grid>
                            </Border>
                            <Border x:Name="Background_Invalid_Unfocused" BorderBrush="#FFCE7D7D" BorderThickness="1" Grid.ColumnSpan="2" Grid.Column="2" CornerRadius="1" Margin="1,1,1,2" Opacity="1" Visibility="Collapsed">
                                <Border BorderThickness="1">
                                    <Border.BorderBrush>
                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                            <GradientStop Color="#FFEBF4FD"/>
                                            <GradientStop Color="#FFDBEAFD" Offset="1"/>
                                        </LinearGradientBrush>
                                    </Border.BorderBrush>
                                    <Border.Background>
                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                            <GradientStop Color="#FFFCDCDC"/>
                                            <GradientStop Color="#FFFCC1C1" Offset="1"/>
                                        </LinearGradientBrush>
                                    </Border.Background>
                                </Border>
                            </Border>
                            <Border x:Name="Background_Disabled" BorderBrush="#FFF8F8F8" BorderThickness="1" Background="#FFE0E0E0" Grid.ColumnSpan="2" Grid.Column="2" Margin="0,0,1,1" Visibility="Collapsed"/>
                            <ContentPresenter x:Name="PART_ContentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="Padding" Value="5,0,3,0"/>
            <Setter Property="BorderBrush" Value="#FFCBCBCB"/>
            <Setter Property="BorderThickness" Value="0,0,1,0"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="SnapsToDevicePixels" Value="True"/>
            <Setter Property="FocusVisualStyle">
                <Setter.Value>
                    <Style>
                        <Setter Property="Control.Template">
                            <Setter.Value>
                                <ControlTemplate>
                                    <Border BorderBrush="#FF848484" BorderThickness="1" CornerRadius="1" Margin="1,1,2,2"/>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Resources>
    <Grid>
        <telerik:RadGridView ItemsSource="{Binding Items}" />
    </Grid>
</Window>

MainWindow.xaml.cs:
using System.Windows;
 
namespace TelerikGridViewCellStyle
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            DataContext = new ViewModel();
        }
    }
}

ViewModel.cs:
using System;
using System.Collections;
using System.Collections.ObjectModel;
using System.ComponentModel;
 
namespace TelerikGridViewCellStyle
{
    public class ViewModel
    {
        public ObservableCollection<DataItem> Items { get; set; }
 
        public ViewModel()
        {
            Items = new ObservableCollection<DataItem>();
            Items.Add(new DataItem {A = "ABC", B = "hihi"});
            Items.Add(new DataItem {A = "DEF", B = "hihi"});
            Items.Add(new DataItem {A = "GHI", B = "hihi"});
        }
    }
 
    public class DataItem : INotifyDataErrorInfo
    {
        public string A { get; set; }
        public string B { get; set; }
 
        public IEnumerable GetErrors(string propertyName)
        {
            return "Error";
        }
 
        public bool HasErrors { get { return true; } }
        public event EventHandler<DataErrorsChangedEventArgs> ErrorsChanged;
    }
}
Michael
Top achievements
Rank 1
 answered on 10 Apr 2013
4 answers
148 views
I installed the WPF SP1 update this morning to my application and it removed my Implicit Theme.  Did I do something wrong?  Should I have chosen the No-XAML version during the Upgrade?  How do I re-add my Theme correctly?  I found the binaries for that theme but now it crashes when I start Debugging.



EDIT:

Never mind, I still don't understand why it removed my Theme dll references but I was able to re add my implicit theme.
N Mackay
Top achievements
Rank 1
 answered on 10 Apr 2013
2 answers
160 views
If I have an object that looks like this:
Object
customerid
value
date

I now want to have the X-axis grouped on the customerid (the same id occurs more than once). This I can do with the CategoryBinding. I'm using a ChartDataSource as the ItemSource for the Series.
Now all the values of the customerId will be displayed next to each other. What I would want to do is to only show one bar for each of the customerId and the value to use an aggregate function (e.g. sum, mean, min, max). The best way I have been able to do this is with the SamplingThreshold. But this is not correct as it could generate multiple bars for one customerId while another one is not displayed at all as the number of occurrences differ. 
I am able to show the aggregated value grouped on date using SamplingUnit and SampleInterval. But I also want to be able to group on other types than just dates.

I am doing this all in code-behind.

I might have missed something completely or be doing something wrong but I have not found a way to achieve it.
How should I go about doing this?
Anonymous
Top achievements
Rank 1
 answered on 10 Apr 2013
1 answer
559 views
I have a toolbar with a button that executes a command. When the command is executed, I set a property from code behind:
SetValue(IsRunningProperty, true);

A worker thread does some work, and when completed the property is updated again:
SetValue(IsRunningProperty, false);

The toolbar binds to this property as follows:
<telerik:RadButton Margin="2" Command="{StaticResource Commands.Run}" IsEnabled="{Binding IsRunning, Converter={StaticResource InverseBooleanConverter}}">
  <Image Stretch="None" Source="..." />
</telerik:RadButton>

This works as long as the toolbar is not focused. If I press the button and wait for my worker to complete, the button will remain disabled until I click in my RadDiagram.

Why isn't the toolbar updating immediately?

UPDATE: Ok, it seems this is caused by a call to someOtherWindow.Focus(). Still, why doesn't the toolbar update itself?
Petar Mladenov
Telerik team
 answered on 10 Apr 2013
3 answers
142 views
I am trying to create a universal Behavior for my application for DragNDrop using your infrastructure.

I would like to bind an items datacontext to a property of my DragDropBehavior but your abstract class inherits from DependencyObject instead of FrameworkElement so it doesn't work.

Can you change this class:
public abstract class DragDropBehavior<TState> : DependencyObject, IDragDropBehavior<TState> where TState : DragDropState

To this in the future:
public abstract class DragDropBehavior<TState> : FrameworkElement, IDragDropBehavior<TState> where TState : DragDropState
Nick
Telerik team
 answered on 10 Apr 2013
1 answer
224 views
I have this situation! I have a MVVM application and the code for the tree:
<telerik:RadTreeView
    IsExpandOnSingleClickEnabled="True"
    ItemsSource="{Binding DLYReasons, Mode=TwoWay}"
    SelectedItem ="{Binding SelectedTreeItem, Mode=TwoWay}">
    <telerik:RadTreeView.ItemContainerStyle>
        <Style TargetType="{x:Type telerik:RadTreeViewItem}">
            <Setter Property="FontWeight" Value="Normal" />
        </Style>
    </telerik:RadTreeView.ItemContainerStyle>
 
    <telerik:RadTreeView.ItemTemplate>
        <HierarchicalDataTemplate ItemsSource="{Binding ChildElements}">
            <StackPanel Orientation="Horizontal">
                <Border MaxHeight="20" MaxWidth="20" MinHeight="20" MinWidth="20"
                        Background="{Binding ImageResourceId, Converter={StaticResource valueToStaticResource}, ConverterParameter={StaticResource StaticResourceValuesTreeShape}}"/>
                <Label Content="{Binding ReasonCode}"></Label>
            </StackPanel>
        </HierarchicalDataTemplate>
    </telerik:RadTreeView.ItemTemplate>
</telerik:RadTreeView>


When I refresh the tree I want to select the previous item and expand it downto the level where this item resides.

Luka 
Pavel R. Pavlov
Telerik team
 answered on 10 Apr 2013
3 answers
211 views
Hi,

First, let me say that the RadDataForm is a great control, i love it, i need only this bit to make it perfect for me:

I am trying to template the DataFormComboBoxField and DataFormDataField. I want them to look in Disabled mode like they look in Edit mode, for example, i want the Combobox 100% opacity but only the triangle will be light grey, and the textboxes will have the border.

I have 2 problems, the first one :
for some reason i cannot get to the nested DataFormComboBoxField and DataFormDataField in Blend, so i cant edit them.

the second problem:
i tried to achieve the above look with RadComboBox, i edited the ChromeButton and some parts of the style and it worked well, but my app using the Windows8 theme, and the edited style using the default office black theme, i saw in the documentation that i should:
"....manually copy the style, together with all resources it has a reference to, from RadControls installation folder on your machine. This folder contains a Themes folder in which you can find resources for RadComboBox or any other control according to the theme you use...."

 - sorry, but i couldn't find a way to make it work.

i spent a ridiculous  amount of time on it, so a step-by-step will be appreciated. BTW, i am sure i am not the only one that asking for this look of the controls, i think it really should be included in the controls.

Thanks. M.

  
Maya
Telerik team
 answered on 10 Apr 2013
1 answer
198 views
Hi,

What is the best practices for the following situation?

1) I have a MainWindow / Menu / MenuItemA
    I click MenuItem and want another window to display say [EditWindow].

2) from [EditWindow] i want to click /Contextmenu/MenuItemB and open yet another form [AnotherEditWindow]

Does Telerik provide some type of messaging system, mediator pattern?

How should this be coded to MVVM standards, I've read the MenuItemB.Command executes on MainWIndowViewModel, raising an event that
MainWIndow has subscribed too. In code behind i create EditWIndow.

Same for EditWindow, MenuItemB.Command executes on EditWindowViewModel, raising an event that EditWindow has subscribed too, and creates AnotherEditWindow.

OR.

just use routedEvents to code behind and create new windows like Winforms development?

OR

Use some framework?

Thanks
Gary


Ivo
Telerik team
 answered on 10 Apr 2013
1 answer
58 views
In the release 2013Q1sp1, I have a serious binding exception when code change a binding property value. it because I send property changed event in a back work thread, and control may not handle invoke requirement and correct work in cross thread status. In older version ,everything is ok, so in 2013Q1sp1 must do some changes.
I use a demo project and change some code to show this issue, the project can work well in 2013Q1, but have exception in 2013Q1sp1

MainWindow.xaml:

 

<Window x:Class="RadControlsWpfApp17.MainWindow"
                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"
                Title="MainWindow" Height="350" Width="525">
        <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="30" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <telerik:RadToolBar>
            <Button Command="{Binding ChangeCommand}" Content="Change Begin" Height="24" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Top" Width="81" />
        </telerik:RadToolBar>
        <telerik:RadGridView ItemsSource="{Binding Data}" GroupRenderMode="Flat"
                             AutoGenerateColumns="False"
                             CanUserFreezeColumns="False"
                             RowIndicatorVisibility="Collapsed"
                             IsFilteringAllowed="False"  Grid.Row="1">
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" />
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Change, StringFormat=f4}"
                                             />
                <telerik:GridViewDataColumn DataMemberBinding="{Binding LastUpdate}"
                                            Header="Last Update" />
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>
    </Grid>
</Window>

MainWindow.xaml.cs
using System.Windows;
  
namespace RadControlsWpfApp17
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            DataContext = new TestDataContext();
        }
    }
}

TestDataContext.cs

using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
using System.Timers;
using Telerik.Windows.Controls;
using Telerik.Windows.Data;
  
namespace RadControlsWpfApp17
{
    class TestDataContext
    {
        readonly string letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        Random rnd = new Random();
  
        public DelegateCommand ChangeCommand
        {
            get
            {
                return new DelegateCommand((o)=>
                    {
                        Task.Factory.StartNew(() =>
                        {
                            System.Timers.Timer t=new Timer();
                            t.Interval = 100;
                            t.Elapsed += new ElapsedEventHandler((sender, e) =>
                                {
                                    int index = this.rnd.Next(0, this.Source.Count());
                                    StockData item = this.CreateNewStockItem();
                                    this.Source[index].Name = e.SignalTime.ToString();
                                });
                            t.Start();
                        });
                    });
            }
        }
  
        ObservableCollection<StockData> source;
        ObservableCollection<StockData> Source
        {
            get
            {
                if (this.source == null)
                {
                    this.source = new ObservableCollection<StockData>(from i in Enumerable.Range(0, 50) select this.CreateNewStockItem());
  
                }
  
                return this.source;
            }
        }
  
        private StockData CreateNewStockItem()
        {
            var item = new StockData();
            this.SetRandomPropertyValues(item);
            return item;
        }
  
        private void SetRandomPropertyValues(StockData item)
        {
            item.Name = String.Format("{0}{1}{2}{3}", this.letters[this.rnd.Next(0, this.letters.Count())], this.letters[this.rnd.Next(0, this.letters.Count())],
                this.letters[this.rnd.Next(0, this.letters.Count())], this.letters[this.rnd.Next(0, this.letters.Count())]);
            item.LastUpdate = DateTime.Now;
            item.Change = this.rnd.NextDouble();
        }
  
        QueryableCollectionView data;
        public QueryableCollectionView Data
        {
            get
            {
                if (this.data == null)
                {
                    this.data = new QueryableCollectionView(Source);
                    this.data.SortDescriptors.Add(new SortDescriptor()
                    {
                        Member = "Name",
                        SortDirection = System.ComponentModel.ListSortDirection.Descending
                    });
                }
  
                return this.data;
            }
        }
    }
    public class StockData : INotifyPropertyChanged
    {
        private string name;
        public string Name
        {
            get
            {
                return this.name;
            }
            set
            {
                if (this.name != value)
                {
                    this.name = value;
                    this.OnPropertyChanged("Name");
                }
            }
        }
  
        private double change;
        public double Change
        {
            get
            {
                return this.change;
            }
            set
            {
                if (this.change != value)
                {
                    this.change = value;
                    this.OnPropertyChanged("Change");
                }
            }
        }
  
        private DateTime lastUpdate;
        public DateTime LastUpdate
        {
            get
            {
                return this.lastUpdate;
            }
            set
            {
                if (this.lastUpdate != value)
                {
                    this.lastUpdate = value;
                    this.OnPropertyChanged("LastUpdate");
                }
            }
        }
  
        private void OnPropertyChanged(string propertyName)
        {
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
  
        public event PropertyChangedEventHandler PropertyChanged;
    }
}
Vlad
Telerik team
 answered on 10 Apr 2013
1 answer
73 views
Hi,

I need to set the RadContextMenu to FrameworkContentElement such as GridViewDataColumn.
I can set contextmenu to FrameworkElement only!!


Thanks,
Akram
Rosen Vladimirov
Telerik team
 answered on 10 Apr 2013
Narrow your results
Selected tags
Tags
GridView
General Discussions
Chart
RichTextBox
Docking
ScheduleView
ChartView
TreeView
Diagram
Map
ComboBox
TreeListView
Window
RibbonView and RibbonWindow
PropertyGrid
DragAndDrop
TabControl
TileView
Carousel
DataForm
PDFViewer
MaskedInput (Numeric, DateTime, Text, Currency)
AutoCompleteBox
DatePicker
Buttons
ListBox
GanttView
PivotGrid
Spreadsheet
Gauges
NumericUpDown
PanelBar
DateTimePicker
DataFilter
Menu
ContextMenu
TimeLine
Calendar
Installer and Visual Studio Extensions
ImageEditor
BusyIndicator
Expander
Slider
TileList
PersistenceFramework
DataPager
Styling
TimeBar
OutlookBar
TransitionControl
Book
FileDialogs
ToolBar
ColorPicker
TimePicker
SyntaxEditor
MultiColumnComboBox
VirtualGrid
Wizard
ExpressionEditor
NavigationView (Hamburger Menu)
DesktopAlert
WatermarkTextBox
BarCode
SpellChecker
DataServiceDataSource
EntityFrameworkDataSource
RadialMenu
ChartView3D
Data Virtualization
BreadCrumb
ProgressBar
Sparkline
LayoutControl
TabbedWindow
ToolTip
CloudUpload
ColorEditor
TreeMap and PivotMap
EntityFrameworkCoreDataSource (.Net Core)
HeatMap
Chat (Conversational UI)
VirtualizingWrapPanel
Calculator
NotifyIcon
TaskBoard
TimeSpanPicker
BulletGraph
Licensing
WebCam
CardView
DataBar
FilePathPicker
PasswordBox
Rating
SplashScreen
Accessibility
Callout
CollectionNavigator
Localization
AutoSuggestBox
Security
VirtualKeyboard
HighlightTextBlock
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?