TileViewItem Maximized

10 posts, 0 answers
  1. Rick Mueller
    Rick Mueller avatar
    103 posts
    Member since:
    Feb 2010

    Posted 12 Nov 2010 Link to this post

    Hello, A couple questions

    IF a user clicks on a tile to maximize it. Would it be possible to call a event before to maximized.

    The code would be something like:

    private Tile_Click()
     If Tile(1) is Clicked
    {
    messagebox.show
    If ok
    {
    then Tile(1) is Maximized
    else
    messagebox cancel
    message "you don't want to max this tile
    }


    I know the code not even close
    But and snippet would be great

    Thoughts>?

    Rick
  2. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1512 posts

    Posted 15 Nov 2010 Link to this post

    Hello Rick,

    One possible solution is to attache to the PreviewTileStateChanged event and handle it depending on the answer from the MessageBox. For example:

    <telerik:RadTileView x:Name="tileView1"
            PreviewTileStateChanged="RadTileView_PreviewTileStateChanged" MaximizeMode="One">
        <telerik:RadTileViewItem Header="Item 0" />
        <telerik:RadTileViewItem Header="Item 1" />
        <telerik:RadTileViewItem Header="Item 2" />
        <telerik:RadTileViewItem Header="Item 3" />
    </telerik:RadTileView>

    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private bool loaded;
     
        public MainWindow()
        {
            InitializeComponent();
     
            this.Dispatcher.BeginInvoke(new Action(() =>
            {
                this.loaded = true;
            }), System.Windows.Threading.DispatcherPriority.ApplicationIdle);
        }
     
        private void RadTileView_PreviewTileStateChanged(object sender, Telerik.Windows.Controls.PreviewTileStateChangedEventArgs e)
        {
            if (this.loaded)
            {
                RadTileViewItem item = e.OriginalSource as RadTileViewItem;
                if (item.TileState == TileViewItemState.Maximized)
                {
                    bool handled = MessageBox.Show("Are you sure", "", MessageBoxButton.YesNo) == MessageBoxResult.Yes ? false : true;
                    e.Handled = (bool)handled;
                }
            }
        }
    }

    The above code will result in:

    http://www.screencast.com/users/kiril/folders/Jing/media/efb4f636-36e0-43c9-aca7-ef96c1b75103

    Please note that there is a small glitch with the toggle button which will be fixed with the next week's internal build. Let me know how this works for you.

    Best wishes,
    Kiril Stanoev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
  4. Rick Mueller
    Rick Mueller avatar
    103 posts
    Member since:
    Feb 2010

    Posted 15 Nov 2010 Link to this post

    Kiril,
    Thank you for your response.

    It works like you said.

    I do have one more question.

    What if  iw want the messagebox only to appear with a certain tile(max), and the rest of the tiles react the same etc.

    Regards,
    Rick
  5. Rick Mueller
    Rick Mueller avatar
    103 posts
    Member since:
    Feb 2010

    Posted 15 Nov 2010 Link to this post

    private void RadTileView_PreviewTileStateChanged(object sender, Telerik.Windows.Controls.PreviewTileStateChangedEventArgs e)
            {
                if (this.loaded)
                {
      
                    this.PrintTile.Items[1] = e.OriginalSource as RadTileViewItem;
                    if ((this.PrintTile.Items[1] as RadTileViewItem).TileState == TileViewItemState.Maximized)
      
                    {
                        bool handled = MessageBox.Show("Are you sure", "", MessageBoxButton.YesNo) == MessageBoxResult.Yes ? false : true;
                        e.Handled = (bool)handled;
                    }
                }
      
            }
     Its erroring on the parent

    Any thoughts?

    Rick
  6. Alex Fidanov
    Admin
    Alex Fidanov avatar
    636 posts

    Posted 18 Nov 2010 Link to this post

    Hello Rick Mueller,

    Which parent do you have in mind? Looking at the code, does the exception come from this line :

    this.PrintTile.Items[1] = e.OriginalSource as RadTileViewItem; ?


    I am not sure why you are trying to set the tile changing state to the second item in the RadTileView, but did you mean to instantiate this in a new variable like in Kiril's sample:

    RadTileViewItem item = e.OriginalSource as RadTileViewItem; ?


    Is there any particular reason why you would want to do this?

    Regards,
    Alex Fidanov
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for WPF
  7. Rick Mueller
    Rick Mueller avatar
    103 posts
    Member since:
    Feb 2010

    Posted 18 Nov 2010 Link to this post

    Alex,

    I was playing with the idea, that only one tileviewitem would invoke the messagebox.

    I have senerio where the user can freely choose and select any tiles to max, But If I need to "lockdown" only one tile. The user would need a clearance to max that one certain tile.

    I hope that makes sense

    Thoughts

    Rick
  8. Alex Fidanov
    Admin
    Alex Fidanov avatar
    636 posts

    Posted 19 Nov 2010 Link to this post

    Hello Rick Mueller,

    In this scenarion, Kirils code is very close to what you are trying to achieve. The only thing you need to add is a way to determine how the RadTileViewItem will be designated for lockdown. You could set its Tag property to some value, showing that it is under lockdown and displaying a MessageBox if the Tag is set, or you could create your own attached property for the RadTileViewItem class and check its value in the
    PreviewTileStateChanged event.

    Best wishes,
    Alex Fidanov
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for WPF
  9. Rick Mueller
    Rick Mueller avatar
    103 posts
    Member since:
    Feb 2010

    Posted 19 Nov 2010 Link to this post

    Alex,,
    Thank you

    Your talking way beyond my learning curve.
    I'll try my best to resolve my sitution you gave me..

    Rick
  10. Rick Mueller
    Rick Mueller avatar
    103 posts
    Member since:
    Feb 2010

    Posted 25 Nov 2010 Link to this post

    Kiril,

    Thanks,
    But i can't figure it out,, Is there a way to lock the Tileview so it can't max, min, and restore with code behind?
  11. Alex Fidanov
    Admin
    Alex Fidanov avatar
    636 posts

    Posted 29 Nov 2010 Link to this post

    Hello Rick Mueller,

    Please find the attached sample showing how you can lock an item so that it cannot be maximized. The idea is the same with any state you want to lock it down. If you want to block it from any state, just handle the event without checking its TileState. Let me know if you have questions on this.

    Greetings,
    Alex Fidanov
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for WPF
Back to Top
UI for WPF is Visual Studio 2017 Ready