style trigger

7 posts, 1 answers
  1. Robert
    Robert avatar
    56 posts
    Member since:
    Sep 2011

    Posted 24 Oct 2013 Link to this post

    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?

  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 29 Oct 2013 Link to this post

    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 >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 01 Nov 2013 Link to this post

    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 >>
  5. Robert
    Robert avatar
    56 posts
    Member since:
    Sep 2011

    Posted 01 Nov 2013 Link to this post

    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.
  6. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 05 Nov 2013 Link to this post

    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 >>
  7. Robert
    Robert avatar
    56 posts
    Member since:
    Sep 2011

    Posted 05 Nov 2013 Link to this post

    I downloaded project, reviewed it, and ran it.  It behaves as expected without the need to use autoGeneratingTile.

    Thanks!
  8. Answer
    Maya
    Admin
    Maya avatar
    4062 posts

    Posted 06 Nov 2013 Link to this post

    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 >>
Back to Top
UI for WPF is Visual Studio 2017 Ready