<
telerikDocking:RadDocking.DocumentHost
><
br
>
<
telerikDocking:RadSplitContainer
x:Name
=
"selectedItemBinder"
><
br
>
<
b
><
telerik:RadPaneGroup
DataContext
=
"{Binding Panes}"
x:Name
=
"radPaneGroup"
SelectedItem
=
"{Binding ElementName=selectedItemBinder, Path=DataContext.SelectedPane, Mode=TwoWay}"
local:RadPaneExtension.ItemsSource
=
"{Binding}"
/></
b
><
br
>
</
telerikDocking:RadSplitContainer
><
br
>
</
telerikDocking:RadDocking.DocumentHost
>
<
Window
x:Class
=
"DockedPaneOverflow.MainWindow"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
xmlns:sample
=
"clr-namespace:DockedPaneOverflow"
Title
=
"MainWindow"
Height
=
"350"
Width
=
"525"
>
<
telerik:RadDocking
>
<
telerik:RadSplitContainer
InitialPosition
=
"DockedLeft"
Width
=
"240"
>
<
telerik:RadPaneGroup
>
<
telerik:RadPane
>
<
sample:UserControl1
></
sample:UserControl1
>
</
telerik:RadPane
>
</
telerik:RadPaneGroup
>
</
telerik:RadSplitContainer
>
<
telerik:RadDocking.DocumentHost
>
<
telerik:RadSplitContainer
>
<
telerik:RadPaneGroup
>
</
telerik:RadPaneGroup
>
<
telerik:RadPaneGroup
>
</
telerik:RadPaneGroup
>
</
telerik:RadSplitContainer
>
</
telerik:RadDocking.DocumentHost
>
</
telerik:RadDocking
>
</
Window
>
<
UserControl
x:Class
=
"DockedPaneOverflow.UserControl1"
xmlns:sample
=
"clr-namespace:DockedPaneOverflow"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
mc:Ignorable
=
"d"
d:DesignHeight
=
"300"
d:DesignWidth
=
"300"
>
<
UserControl.Resources
>
<
sample:RadGridViewSampleData
x:Key
=
"DataSource"
/>
</
UserControl.Resources
>
<
Grid
>
<
Grid.ColumnDefinitions
>
<
ColumnDefinition
></
ColumnDefinition
>
</
Grid.ColumnDefinitions
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
"15px"
></
RowDefinition
>
<
RowDefinition
Height
=
"*"
></
RowDefinition
>
</
Grid.RowDefinitions
>
<
Canvas
Grid.Column
=
"0"
Grid.Row
=
"0"
>
<
Menu
>
<
MenuItem
Header
=
"Level 1"
>
<
MenuItem
Header
=
"Level 1.1"
/>
</
MenuItem
>
</
Menu
>
</
Canvas
>
<
Canvas
Grid.Column
=
"0"
Grid.Row
=
"1"
>
<
telerik:RadGridView
x:Name
=
"radGridView"
Margin
=
"8"
ItemsSource
=
"{Binding Source={StaticResource DataSource}, Path=Cars}"
Width
=
"600px"
Height
=
"394px"
/>
</
Canvas
>
</
Grid
>
</
UserControl
>
Hi,
I am still rather new to WPF in general but trying to come up to speed. I am using RadTileList in an app. I am using it for "recent items" in an application. Those items point to different modules. These modules are color coded. So when the tile renders, I want to select a particular background color of the tile, e.g. Employees = green, Crm = blue, etc.
I am using ItemsSource to a view model property
Here is the main radTileList
<telerik:RadTileList
CanUserSelect="False"
x:Name="HomeTileList"
ItemsSource="{Binding Path=RecentItems}"
GroupTemplate="{StaticResource GroupTemplate}"
Margin="5,5,0,0"
TileReorderMode="None"
ScrollViewer.HorizontalScrollBarVisibility="Auto">
....
I put in this style
<Style TargetType="telerik:Tile" >
<Setter Property="TileType" Value="Single" />
<Setter Property="Group" Value="{StaticResource tgRecent}" />
<!--<Setter Property="Background" Value="{Binding ModuleCode, Converter={StaticResource StringToTileBackgroundConverter}}"/>-->
<Setter Property="Background" Value="{StaticResource ModuleSolicitation}" />
<Setter Property="Background" Value="Black" />
<Style.Triggers>
<DataTrigger Binding="{Binding EntityId}" Value="1">
<Setter Property="Background" Value="Red" />
</DataTrigger>
</Style.Triggers>
</Style>
I have tried a value converter and a dataTrigger. In the current form, the app picks up the "black" background, but it does not seem to be checking against the EntityId field to render a Red tile.
Note: I eventually want to tied the background color based on the ModuleCode which is an enum. But I am doing EntityId for testing so that that I can have 1=1 so to speak while I figure this out.
this is "RecentItems" as the collection from the dataContext of the view.
public ObservableCollection<RecentItemViewModel> RecentItems { get; private set; }
and here is the class
public class RecentItemViewModel : ViewModelBase
{
private int _entityId;
private string _entityName;
private Enums.Module _moduleCode;
public int EntityId
{
get { return _entityId; }
set
{
if ((_entityId != value))
{
_entityId = value;
RaisePropertyChanged("EntityId");
}
}
}
public string EntityName
{
get { return _entityName; }
set
{
if ((_entityName != value))
{
_entityName = value;
RaisePropertyChanged("EntityName");
}
}
}
public Enums.Module ModuleCode
{
get { return _moduleCode; }
set
{
if ((_moduleCode != value))
{
_moduleCode = value;
RaisePropertyChanged("ModuleCode");
}
}
}
}
any ideas?
namespace Examples.TransitionControl.Common
{
public static class RotatorExtensions
{
public static readonly DependencyProperty ItemsSourceProperty =
DependencyProperty.RegisterAttached("ItemsSource", typeof(IEnumerable), typeof(RotatorExtensions), new PropertyMetadata(null, OnItemsSourceChanged));
public static readonly DependencyProperty ItemChangeDelayProperty =
DependencyProperty.RegisterAttached("ItemChangeDelay", typeof(Duration), typeof(RotatorExtensions), new PropertyMetadata(new Duration(TimeSpan.FromSeconds(0.3))));
public static readonly DependencyProperty CurrentSelectedIndexProperty =
DependencyProperty.RegisterAttached("CurrentSelectedIndex", typeof(int), typeof(RotatorExtensions), new PropertyMetadata(-1, OnCurrentSelectedIndexChanged));
private static readonly DependencyProperty TimerProperty =
DependencyProperty.RegisterAttached("Timer", typeof(DispatcherTimer), typeof(RotatorExtensions), null);
public static IEnumerable GetItemsSource(DependencyObject obj)
{
return (IEnumerable)obj.GetValue(ItemsSourceProperty);
}
public static void SetItemsSource(DependencyObject obj, IEnumerable value)
{
obj.SetValue(ItemsSourceProperty, value);
}
public static Duration GetItemChangeDelay(DependencyObject obj)
{
return (Duration)obj.GetValue(ItemChangeDelayProperty);
}
public static void SetItemChangeDelay(DependencyObject obj, Duration value)
{
obj.SetValue(ItemChangeDelayProperty, value);
}
public static int GetCurrentSelectedIndex(DependencyObject obj)
{
return (int)obj.GetValue(CurrentSelectedIndexProperty);
}
public static void SetCurrentSelectedIndex(DependencyObject obj, int value)
{
obj.SetValue(CurrentSelectedIndexProperty, value);
}
private static DispatcherTimer GetTimer(DependencyObject obj)
{
return (DispatcherTimer)obj.GetValue(TimerProperty);
}
private static void SetTimer(DependencyObject obj, DispatcherTimer value)
{
obj.SetValue(TimerProperty, value);
}
private static void OnCurrentSelectedIndexChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
UpdateCurrentlySelectedItem(d);
}
private static void MoveToNextElement(DependencyObject element)
{
IEnumerable source = GetItemsSource(element);
if (source != null)
{
IEnumerable<
object
> convertedSource = source.Cast<
object
>();
int currentIndex = GetCurrentSelectedIndex(element);
currentIndex = ++currentIndex % convertedSource.Count();
SetCurrentSelectedIndex(element, currentIndex);
}
}
private static void OnItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
FrameworkElement element = d as FrameworkElement;
ItemsControl itemsControl = d as ItemsControl;
IEnumerable oldValue = e.OldValue as IEnumerable;
IEnumerable newValue = e.NewValue as IEnumerable;
if (element != null)
{
if (oldValue != null)
{
// Detach the Ad Rotator functionality.
element.Loaded -= OnElementLoaded;
element.Unloaded -= OnElementUnloaded;
// If there is a timer attached, stop it.
DispatcherTimer timer = GetTimer(element);
if (timer != null)
{
timer.Stop();
}
}
if (newValue != null)
{
// Attach the Ad Rotator functionality.
element.Loaded += OnElementLoaded;
element.Unloaded += OnElementUnloaded;
// If the target is an ItemsControl and its ItemsSource is not set, set it.
if (itemsControl != null && itemsControl.ItemsSource == null && itemsControl.Items.Count == 0)
{
itemsControl.ItemsSource = newValue;
}
}
}
}
private static DependencyObject element;
private static void OnElementLoaded(object sender, RoutedEventArgs args)
{
element = sender as DependencyObject;
// Create the timer and hook-up to the events.
DispatcherTimer timer = new DispatcherTimer();
timer.Interval = GetItemChangeDelay(element).TimeSpan;
SetTimer(element, timer);
timer.Tick += new EventHandler(timer_Tick);
timer.Start();
// Make sure the currently pointed element is selected.
UpdateCurrentlySelectedItem(element);
}
static void timer_Tick(object sender, EventArgs e)
{
MoveToNextElement(element);
}
private static void OnElementUnloaded(object sender, RoutedEventArgs args)
{
FrameworkElement element = sender as FrameworkElement;
if (element != null)
{
DispatcherTimer timer = GetTimer(element);
if (timer != null)
{
timer.Stop();
}
}
}
private static void UpdateCurrentlySelectedItem(DependencyObject element)
{
ContentControl contentControl = element as ContentControl;
IEnumerable source = GetItemsSource(element);
// If there is no source we shouldn't do anything.
if (source == null) return;
// Find the actual index to be selected (if outside the boundaries of the collection)
// and find the actual element to be selected.
IEnumerable<
object
> convertedSource = source.Cast<
object
>();
int currentIndex = GetCurrentSelectedIndex(element);
object elementToSelect = convertedSource.ElementAtOrDefault(currentIndex);
// Update the cotnent of the ContentControl if attached to a ContentControl.
if (contentControl != null)
{
contentControl.Content = elementToSelect;
}
}
}
}
<Window x:Class=
"GridGroupingTest.MainWindow"
xmlns:telerik=
"http://schemas.telerik.com/2008/xaml/presentation"
xmlns:entites=
"clr-namespace:GridGroupingTest"
xmlns:system=
"clr-namespace:System;assembly=mscorlib"
Title=
"MainWindow"
Height=
"350"
Width=
"525"
>
<Grid>
<telerik:RadEntityFrameworkDataSource Name=
"AIMEntityFrameworkDataSource"
QueryName=
"DimCustomers"
>
<telerik:RadEntityFrameworkDataSource.ObjectContext>
<entites:AdventureWorksDW2008R2Entities1/>
</telerik:RadEntityFrameworkDataSource.ObjectContext>
</telerik:RadEntityFrameworkDataSource>
<Border Grid.Column=
"0"
BorderBrush=
"Black"
BorderThickness=
"2"
Margin=
"2"
>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width=
"Auto"
/>
<ColumnDefinition Width=
"*"
/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height=
"Auto"
/>
<RowDefinition Height=
"*"
/>
<RowDefinition Height=
"Auto"
/>
</Grid.RowDefinitions>
<Label Content=
"Columns Shown:"
Grid.Row=
"0"
Grid.Column=
"0"
/>
<StackPanel Background=
"White"
Grid.Row=
"1"
Grid.Column=
"0"
Grid.RowSpan=
"2"
>
<ListBox ItemsSource=
"{Binding Columns, ElementName=RadGridView1}"
>
<ListBox.ItemTemplate>
<DataTemplate>
<CheckBox Content=
"{Binding Header}"
IsChecked=
"{Binding IsVisible, Mode=TwoWay}"
/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
<StackPanel Orientation=
"Horizontal"
Grid.Row=
"0"
Grid.Column=
"1"
>
<Label Content=
"Filters"
/>
<telerik:RadComboBox Margin=
"2"
Width=
"150"
DisplayMemberPath=
"name"
ItemsSource=
"{Binding Filters}"
SelectedItem=
"{Binding SelectedFilter, Mode=TwoWay}"
/>
<Button Command=
"{Binding LoadFilterCommand}"
Content=
"Load"
/>
<Button Command=
"{Binding DeleteFilterCommand}"
Content=
"Delete"
/>
<Label Content=
"Save Filter Name:"
/>
<TextBox x:Name=
"SaveNameTextbox"
Text=
"{Binding SaveNameText, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
Width=
"150"
/>
<Button Command=
"{Binding SaveFilterCommand}"
Content=
"Save"
/>
<Button Content=
"Default"
/>
<Button Content=
"Clear All"
/>
</StackPanel>
<telerik:RadGridView x:Name=
"RadGridView1"
Grid.Row=
"1"
Grid.Column=
"1"
ItemsSource=
"{Binding DataView, ElementName=AIMEntityFrameworkDataSource}"
Margin=
"0"
GroupRenderMode=
"Flat"
SelectedItem=
"{Binding SelectedIndex}"
DataLoadMode=
"Asynchronous"
RowIndicatorVisibility=
"Collapsed"
IsReadOnly=
"True"
ShowColumnSortIndexes=
"True"
AutoGenerateColumns=
"False"
CanUserFreezeColumns=
"True"
CanUserResizeColumns=
"True"
ValidatesOnDataErrors=
"None"
>
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn Header=
"First"
ShowDistinctFilters=
"False"
DataMemberBinding=
"{Binding FirstName}"
DataType=
"system:String"
/>
<telerik:GridViewDataColumn Header=
"Middle"
ShowDistinctFilters=
"False"
DataMemberBinding=
"{Binding MiddleName}"
DataType=
"system:String"
/>
<telerik:GridViewDataColumn Header=
"Last"
ShowDistinctFilters=
"False"
DataMemberBinding=
"{Binding LastName}"
DataType=
"system:String"
/>
<telerik:GridViewDataColumn Header=
"Email"
ShowDistinctFilters=
"False"
DataMemberBinding=
"{Binding EmailAddress}"
DataType=
"system:String"
/>
<telerik:GridViewDataColumn Header=
"Education"
ShowDistinctFilters=
"False"
DataMemberBinding=
"{Binding EnglishEducation}"
DataType=
"system:String"
/>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
<telerik:RadDataPager x:Name=
"radDataPager"
Grid.Row=
"2"
Grid.Column=
"1"
Source=
"{Binding Items, ElementName=RadGridView1}"
PageSize=
"30"
/>
</Grid>
</Border>
</Grid>
</Window>