This is a migrated thread and some comments may be shown as answers.

style trigger

6 Answers 239 Views
TileList
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 24 Oct 2013, 09:26 PM

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?

6 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 29 Oct 2013, 04:12 PM
Hello Robert,

Actually, it turns out to be a bug in tile list. I have already resolved it and the fix will be available in the internal build coming on next Monday.
I have updated your telerik points.

Regards,
Maya
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Maya
Telerik team
answered on 01 Nov 2013, 02:26 PM
Hello Robert,

As it turns out, we will need a bit more time for investigating the case. I will write you back as soon as I could provide more information on the topic. In the mean time you can try something as follows:

private void HomeTileList_AutoGeneratingTile(object sender, AutoGeneratingTileEventArgs e)
        {
            e.Tile.DataContext = e.Tile.Content;
        }

Thank you for your patience.

Regards,
Maya
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Robert
Top achievements
Rank 1
answered on 01 Nov 2013, 03:25 PM
Thanks.  That "fixes" my problem.  Although, I was originally trying to set background through a converter.  I still tried that one, but it did not seem to work.  Stacking up my style triggers did with the event above did.

I would like to use a converter (less View clutter) becausethe converter can do it in one line.

Thanks you for the feedback and a temporary solution.
0
Maya
Telerik team
answered on 05 Nov 2013, 02:57 PM
Hi Robert,

I have updated the behavior and the change will be available in our next internal build coming on Monday. In the meantime I am attaching a sample project with locally built binaries just to verify this is the result you would expect. Let me know in case something is not correct on you side. 

Regards,
Maya
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Robert
Top achievements
Rank 1
answered on 05 Nov 2013, 09:45 PM
I downloaded project, reviewed it, and ran it.  It behaves as expected without the need to use autoGeneratingTile.

Thanks!
0
Accepted
Maya
Telerik team
answered on 06 Nov 2013, 07:47 AM
Hello Robert,

I am glad to here that. Those binaries will be available with the internal build on Monday. Let me know in case you found other issues.
I am also updating your telerik points for your feedback. Thanks for that. 

Regards,
Maya
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
TileList
Asked by
Robert
Top achievements
Rank 1
Answers by
Maya
Telerik team
Robert
Top achievements
Rank 1
Share this question
or