Telerik Forums
UI for WPF Forum
4 answers
260 views
I am using the PanelBar to display a two level hierarchy of menu items (Menu Sections and Menu Items). I am using a DataTemplate for the menu items and a HierarchicalDataTemplate for the root collection of menu sections. The binding is all working correctly. My problem arose when I attempted to make use of the SelectedItem Property on the PanelBar. When I bound the property to my view model (using either TwoWay or OneWayToSource) when expanding or collapsing the headers, a red border appears around the PanelBar. The animation becomes a little sluggish as well but I can live with that.

If I select one of the items the red border disappears - it will re-appear if I expand or collapse the header.  If I simply remove the binding or set the binding to OneWay the red border does no appear.

With the binding set to TwoWay or OneWayToSource the view model is updated correctly. Any other binding mode results in no update of the view model.

The appearance of the red border will be unacceptable to my client and I would really appreciate any help with how I can get it so stop appearing.

Here are snippets of my XAML:

01.<!-- Menu Item Data Template -->
02.<DataTemplate DataType="{x:Type entities:MenuItemModel}">
03.    <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch">
04.        <StackPanel.ToolTip>
05.            <TextBlock Text="{Binding MenuItemDescription}"
06.                           HorizontalAlignment="Stretch" />
07.        </StackPanel.ToolTip>
08.        <TextBlock Text="{Binding MenuItemText}" HorizontalAlignment="Stretch"/>
09.    </StackPanel>
10.</DataTemplate>
11. 
12.<!-- Menu Section Data Template -->
13.<HierarchicalDataTemplate DataType="{x:Type entities:MenuSectionModel}"
14.                          ItemsSource="{Binding MenuItems}">
15.    <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch">
16.        <StackPanel.ToolTip>
17.            <TextBlock Text="{Binding MenuSectionDescription}"
18.                          HorizontalAlignment="Stretch" />
19.        </StackPanel.ToolTip>
20.        <Image Source="{Binding IconData, Converter={StaticResource StrToImgConverter}}"
21.                        Height="32" Width="32"/>
22.        <TextBlock Text="{Binding MenuSectionText}"
23.                    VerticalAlignment="Center" HorizontalAlignment="Stretch"
24.                      Margin="6,0,0,0"/>
25.    </StackPanel>           
26.</HierarchicalDataTemplate>
27....
28.<telerik:RadPane Header="{Binding ApplicationData.ApplicationName, Mode=OneWay}"
29.     CanUserClose="False" CanFloat="False" CanDockInDocumentHost="False" >
30.    <telerik:RadPanelBar Height="Auto" HorizontalAlignment="Stretch"
31.         ExpandMode="Multiple"
32.             ItemsSource="{Binding ApplicationData.ApplicationMenu.MenuSections}"
33.             SelectionMode="Single"
34.             SelectedItem="{Binding SelectedMenuItem, Mode=OneWayToSource}">
35.     </telerik:RadPanelBar>
36.</telerik:RadPane>
Petar Mladenov
Telerik team
 answered on 15 Oct 2014
3 answers
547 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
355 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
299 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
207 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
148 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
413 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
477 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.2K+ 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
96 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
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
DataPager
PersistenceFramework
Styling
TimeBar
OutlookBar
TransitionControl
FileDialogs
Book
ToolBar
ColorPicker
TimePicker
MultiColumnComboBox
SyntaxEditor
VirtualGrid
NavigationView (Hamburger Menu)
Wizard
ExpressionEditor
WatermarkTextBox
DesktopAlert
BarCode
SpellChecker
DataServiceDataSource
EntityFrameworkDataSource
RadialMenu
ChartView3D
Data Virtualization
BreadCrumb
LayoutControl
ProgressBar
Sparkline
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
Callout
PasswordBox
SplashScreen
Localization
Rating
Accessibility
CollectionNavigator
AutoSuggestBox
Security
VirtualKeyboard
HighlightTextBlock
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
InlineAIAssistant
+? more
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?