Telerik Forums
UI for WPF Forum
3 answers
458 views
Hi,

I'm trying to get the position of a context menu relative to his placement target by using MousePosition property and there is an issue.

Here's what I have :

<telerik:RadContextMenu>
    <telerik:RadMenuItem Header="Add item" Command="{Binging AddItemCommand}" CommandParameter="{Binding MousePosition, RelativeSource={RelativeSource FindAncestor, AncestorType=telerik:RadContextMenu}}"/>
</telerik:RadContextMenu/>

When I click on "Add Item", the position that I received in the viewModel is (Double.NaN, Double.Nan), so I conclued that the value of MousePosition is updated after the evaluation of the bindings. Is there another way to get the MousePosition of the contextMenu that would works with MVVM ?

Thank you,

Etienne
Kalin
Telerik team
 answered on 15 Oct 2014
1 answer
271 views
Hi,

I have a RadTreeView where data is populated from an xml using XmlDataProvider.  I would like to bind the SelectedItem of TreeView to a ViewModel property of type string. When I do the binding using SelectedItem={Binding mydata}", the value mydata is set to System.Xml.XmlElement type.

I was able to find the logic to get the exact value. For testing purpose, I created a new TextBox control to retreive the exact selected data.

 <TextBox  DataContext="{Binding ElementName=ReportersTreeView, Path=SelectedItem}" Grid.Row="6"   Text="{Binding XPath=@Name}"></TextBox>

However in real scenario, I don't need this TextBox. 

I want to know how can I integrate this code to my tree view control such that XPath=@Name is correctly retrieved from SelectedItem  and set to my viewmodel property?

Below is my TreeView control and my Template.

 <HierarchicalDataTemplate x:Key="NodeTemplate">
            <TextBlock x:Name="tb"/>
            <HierarchicalDataTemplate.ItemsSource>
                <Binding XPath="child::node()" />
            </HierarchicalDataTemplate.ItemsSource>
            <HierarchicalDataTemplate.Triggers>
                <!--<DataTrigger Binding="{Binding Path=NodeType}" Value="Text">
                    <Setter TargetName="tb" Property="Text" Value="{Binding XPath = @name}"></Setter>
                </DataTrigger>-->
                <DataTrigger Binding="{Binding Path=NodeType}" Value="Element">
                    <Setter TargetName="tb" Property="Text" Value="{Binding Path=Attributes[Name].Value}"></Setter>
                </DataTrigger>
            </HierarchicalDataTemplate.Triggers>
        </HierarchicalDataTemplate>
        <XmlDataProvider x:Key="ReportersDataProvider" Source="ProbesTree.xml"
                         XPath="*">

 <telerik:RadTreeView Grid.Row="2"  IsDragDropEnabled="True" Name="ReportersTreeView"  SelectionMode="Single" IsSingleExpandPath="False" IsLineEnabled="True"   AutomationProperties.AutomationId ="ReportersTreeView" VerticalAlignment="Stretch"
                ItemTemplate= "{StaticResource NodeTemplate}" ItemsSource="{Binding Source={StaticResource ReportersDataProvider}}"  VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch"/>

Please help.!!!!

Thanks,
Divya
         
Pavel R. Pavlov
Telerik team
 answered on 15 Oct 2014
3 answers
243 views
I have an object that I have some data in. The object has the following properties

Description
Amount
Date

I want to plot a chart where Date would be in X axis and Amount will be on Y (which is easy). If I just set the ItemsSource and the X and Y properties, this works fine.

However for each distinct description I want to show a new series. But I want to keep this dynamic. so if there is Series 1 and Series 2 in Description, then only two would show, if there is more than 2 then all would show. How is this doable?

Petar Marchev
Telerik team
 answered on 15 Oct 2014
8 answers
158 views
Hi

  I don't know what I am asking is can be done, but have to try a shot, Currently using Schedule view for my project, and on that as you people know there is Day,Week,Month and timeline option on it, what I am expecting is, can Onclick event can be done  on "Day" or "week" so that  it can trigger method in viewmodel(class file) currently this click option is nothing to do with Viewmodel, the reason I need this because, if employee has an many appointments Ex 1000, it takes time to load all the 1000 values,so what I need is on page load it should show only todays appointments, on selection of "Week" it should call a method and pass the week parameters to get only week's appointment and so on, I want to get appointment based on selection of Day or Month it has to load only based on that Selection event, not the entire future appointment list, hope I made it understand , Please let me know for any clarification, and I am attaching the pic of existing view of mine, so please guide me in this, any help is appreciated, thanks :)
Kalin
Telerik team
 answered on 15 Oct 2014
1 answer
100 views
Hi

We are trying to do custom sorting per grouping in a datagrid and I've been unable to find any examples. Say we have 2 groups, foo and bar, and we want to sort the row on 2 different properties. The groups are, in this particular example, known and I somehow like to specify a GroupSortingExpression per grouping. 

In the attached screenshot, I would like to sort the group 'group-1' by foo and the group 'group-2' by bar. Is this possible?

Any hints are greatly appreciated!
Regards
/Jasper

using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using Telerik.Windows.Data;
 
namespace WpfApplication2
{
    public class DataItemCollection
    {
        private ObservableCollection<DataItem> _internalItems;
        public ObservableCollection<DataItem> Items
        {
            get
            {
                return _internalItems ?? (_internalItems = new ObservableCollection<DataItem>
                {
                    new DataItem("group-1", "bar-1", "foo-1", new DateTime(2000, 01, 2)),
                    new DataItem("group-1", "bar-3", "foo-3", new DateTime(2000, 01, 1)),
                    new DataItem("group-1", "bar-2", "foo-0", new DateTime(2000, 01, 1)),
                    new DataItem("group-2", "bar-4", "foo-4", new DateTime(2000, 01, 1)),
                    new DataItem("group-2", "bar-2", "foo-2", new DateTime(2000, 01, 4)),
                    new DataItem("group-2", "bar-5", "foo-5", new DateTime(2000, 01, 3))
                });
            }
        }
    }
 
    public class DataItem
    {
        public DataItem(string @group, string bar, string foo, DateTime date)
        {
            Group = @group;
            Bar = bar;
            Foo = foo;
            Date = date;
 
            GroupingInfo = new DataGroupingInfo(@group);
 
             
        }
 
        public string Foo { get; set; }
 
        public string Group { get; set; }
 
        public string Bar { get; set; }
 
        public DateTime Date { get; set; }
 
        public DataGroupingInfo GroupingInfo { get; set; }
    }
 
    public class DataGroupingInfo : IEquatable<DataGroupingInfo>, IComparable<DataGroupingInfo>, IComparable
    {
        public DataGroupingInfo(string p1)
        {
            Property1 = p1;
        }
 
        public string Property1 { get; set; }
 
        public bool Equals(DataGroupingInfo other)
        {
            return other.Property1 == Property1;
        }
 
        public int CompareTo(DataGroupingInfo other)
        {
            return String.Compare(Property1, other.Property1, StringComparison.Ordinal);
        }
 
        public override int GetHashCode()
        {
            return (Property1 != null ? Property1.GetHashCode() : 0);
        }
 
        public int CompareTo(object obj)
        {
            return CompareTo((DataGroupingInfo) obj);
        }
    }
 
    public class DataItemInfoGroupDescriptor : GroupDescriptor<DataItem, DataGroupingInfo, string>
    {
        public DataItemInfoGroupDescriptor()
        {
            GroupingExpression = t => t.GroupingInfo;
             
            GroupSortingExpression = g => g.Key.Property1;
        }
 
        public override ListSortDirection? SortDirection
        {
            get { return ListSortDirection.Ascending; }
        }
    }
}

Dimitrina
Telerik team
 answered on 15 Oct 2014
4 answers
319 views
Hi There,

when the RadWatermarkTextBox is readonly and then we focus the RadWatermarkTextBox on pressing tab I have to set "FocusedVisual" border to "collapsed"(In the Template), but when user tries focus the text box then the "FocusedVisual" should be enabled. can you please help us.

Here is my style:

<Style x:Key="RadWatermarkTextBoxStyle" TargetType="telerik:RadWatermarkTextBox">
        <Setter Property="CaretBrush" Value="#FF516066"/>
        <Setter Property="Height" Value="24"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Padding" Value="4,0"/>
        <Setter Property="AllowDrop" Value="true"/>
        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
        <Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
        <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
        <Setter Property="Validation.ErrorTemplate" Value="{x:Null}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="telerik:RadWatermarkTextBox">
                <Grid x:Name="RootElement" Cursor="IBeam">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <ColorAnimation Duration="0" Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)" To="#FF0166A1" Storyboard.TargetName="Border"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="DisabledVisual" Storyboard.TargetProperty="Opacity" To="1" Duration="0"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="ReadOnly">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="ReadOnlyVisual" Storyboard.TargetProperty="Opacity" To="1" Duration="0" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Focused">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="Border" Storyboard.TargetProperty="Opacity" To="0" Duration="0" />
                                        <DoubleAnimation Storyboard.TargetName="FocusedVisual" Storyboard.TargetProperty="Opacity" To="1" Duration="0"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Unfocused"/>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="ValidationStates">
                                <VisualState x:Name="Valid"/>
                                <VisualState x:Name="InvalidUnfocused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ValidationErrorVisual" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ThicknessAnimation Duration="0" To="1" Storyboard.TargetName="ValidationErrorVisual" Storyboard.TargetProperty="BorderThickness"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="InvalidFocused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ValidationErrorVisual" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ThicknessAnimation Duration="0" To="2" Storyboard.TargetName="ValidationErrorVisual" Storyboard.TargetProperty="BorderThickness"/>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ValidationTooltip" Storyboard.TargetProperty="IsOpen">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <sys:Boolean>True</sys:Boolean>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="WatermarkStates">
                                <VisualState x:Name="WatermarkHidden"/>
                                <VisualState x:Name="WatermarkVisible">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="WatermarkVisual" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0:0:0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>
                                                        Visible
                                                    </Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <DoubleAnimation Duration="0" To="0.5" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="WatermarkVisual"/>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Border x:Name="BaseBorder" Background="#FFFFFFFF" Margin="1"/>
                        <Border x:Name="ReadOnlyVisual" Background="#FFDFE3E6" BorderBrush="#FFA6A6A6" BorderThickness="1" Opacity="0"/>
                        <Border x:Name="Border" BorderThickness="1" BorderBrush="#FF8F8F8F"/>
                        <ScrollViewer x:Name="PART_ContentHost" Padding="{TemplateBinding Padding}" BorderThickness="0" IsTabStop="False"/>
                        <Border x:Name="MouseOverVisual" BorderThickness="2" BorderBrush="Transparent"/>
                        <Border x:Name="FocusedVisual" BorderThickness="2" BorderBrush="#FF0166A1" IsHitTestVisible="False" Opacity="0"/>
                        <Border x:Name="DisabledVisual" Background="#A5F7F7F7" BorderBrush="#A5F7F7F7" BorderThickness="{TemplateBinding BorderThickness}" Opacity="0" IsHitTestVisible="False"/>
                        <Border x:Name="ValidationErrorVisual" BorderThickness="2" BorderBrush="Red" Visibility="Collapsed"/>
                        <ContentControl x:Name="WatermarkVisual" Visibility="Collapsed" Content="{TemplateBinding WatermarkContent}" ContentTemplate="{TemplateBinding WatermarkTemplate}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" IsHitTestVisible="False" Margin="6,0" />
                        <Border Visibility="Collapsed">
                            <ToolTipService.ToolTip>
                                <ToolTip 
x:Name="ValidationTooltip" 
PlacementTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}"
Content="{Binding Path=(Validation.Errors),Converter={StaticResource validationErrorConverter}}"/>
                            </ToolTipService.ToolTip>                            
                        </Border>
                       </Grid>
                </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>





Ravi
Top achievements
Rank 1
 answered on 15 Oct 2014
1 answer
406 views
Hello,
In this demo: http://demos.telerik.com/silverlight/#ImageEditor/Cropping you use BitmapToRadBitmapImageConverter. Can you please share the code for the converter?

I suppose it is something like this:

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var image = value as BitmapImage;
            if(image != null)
                return new RadBitmap(image);

            return null;
        }

But will be good to have the original code.

Regards,
Saykor
Petya
Telerik team
 answered on 14 Oct 2014
3 answers
1.0K+ views
I am using the the Windows7Theme for my application and I want to do so for RadToggleButtons too...but I need it to have a more pronounced background color when checked (like the Office Blue theme which highlights the control in yellow). What is the easiest way to accomplish this?

Thanks.
Martin Ivanov
Telerik team
 answered on 14 Oct 2014
5 answers
55 views
We have the "TileReorderMode" property set to "None" - but when using your finger to scroll left and right the tiles they still move up and down somewhat -- which messing with scrolling smoothly.  Is there a way to stop this individual tile movement?

When we have the tile's "InEnabled" set to "False" - this allows for the desired smooth scrolling - but still need a way to trigger actions when clicking / touching the tiles -- and can't get any events to fire when tiles are disabled...

Would love a solution for either of the two situations above...
Yoan
Telerik team
 answered on 14 Oct 2014
1 answer
185 views
Hello

I have some problems with drag and drop inside RadListBox. Everything is fine but it only works for first element in RadListBox - I mean that I can drag only first item down in any place, but only the first one. When I create a separate project everything works fine but it is not working in my application. I can't send any example of it and that a shame but I have a question. Is it possible that only first element can be dragged? 

What can be wrong, maybe some property needs to be set for other items when drag is being initialized? OnDragInitializeHandler is being fired but nothing after that. Many thanks for your advice.
Nasko
Telerik team
 answered on 14 Oct 2014
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?