AnimatedStackPanel, command binding

Views for WPF Forum

Posted 13 years ago by Chris Baker
Version: 11.1.0541
Avatar
AnimatedStackPanel

How do I move the panel left and right? I would like to do this within XAML

I have tried
<ItemsPanelTemplate>
<views:AnimatedStackPanel
x:Name="AnimationSP"
Loaded="AnimationSP_Loaded">
</views:AnimatedStackPanel>
</ItemsPanelTemplate>

public View(ViewModel viewModel)
{
InitializeComponent();

ActiproSoftware.Windows.Controls.Views.AnimatedStackPanel test = AnimationSP
}

And it does not work.


This does
private void AnimationSP_Loaded(object sender, RoutedEventArgs e)
{
animationSP = (AnimatedStackPanel)sender;
}

private void ImageButton_Click(object sender, RoutedEventArgs e)
{
animationSP.LineLeft();
}

Both are not very nice. I looked at your commanding example with Books but cannot get this work. Can you please help?

We are not a customer yet, but looking into buying if this does what we need.

Thanks in advance
Chris

Comments (3)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Chris,

In nearly all WPF controls scrolling support is provided by using a ScrollViewer. Some controls, like ListBox have the ScrollViewer included in their ControlTemplate, so you don't have to explictly use it.

In addition, there are two types of scrolling: physical and logical. Physical is basically pixel-by-pixel scrolling. Logical scrolling allows you to provide customized scrolling. In the case of StackPanel (and our AnimatedStackPanel), it will scroll item-by-item in the orientation direction, and pixel-by-pixel in the other direction.

Panels do not scroll by themselves, even if they support logical scorlling. They must still be wrapped in a ScrollViewer that has CanContentScroll set to true.

It's hard to tell what the issue can be based on the code you provided. If you can please put together a small sample project that reproduces your issue and email it over then we can take a closer look. Be sure to remove any executables or change the extension of the zip file to ensure it gets past our email filters.


Actipro Software Support

Posted 13 years ago by Chris Baker
Avatar
Thanks for the reply, I will try to put an example together when I get some more time. Maybe if I ask the question in a different way for now.

How do I call LineLeft() and LineRight() from code behind?
You expose these methods on the AnimatedStackPanel so I should be able to call then from code?

Thanks
Chris
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Chris,

I apolygize, I thought by "Both are not very nice" you meant that there was a visual artifact. Unfortunately, you'd have to traverse the visual tree to get at the AnimatedStackPanel. But really you can just look for the ScrollViewer, as this is a more generic approach. So assuming you have this:
<ListBox x:Name="listBox">
    <ListBox.ItemsPanel>
        <ItemsPanelTemplate> 
            <views:AnimatedStackPanel /> 
        </ItemsPanelTemplate> 
    </ListBox.ItemsPanel>
</ListBox>
Then you could access it like:
private void ImageButton_Click(object sender, RoutedEventArgs e) { 
    var scrollViewer = VisualTreeHelperExtended.GetFirstDescendant(this.listBox, typeof(ScrollViewer)) as ScrollViewer;
    if (scrollViewer != null)
        scrollViewer.LineLeft(); 
}


Actipro Software Support

The latest build of this product (v24.1.2) was released 7 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.