Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7626693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:21:35+00:00 2026-05-31T05:21:35+00:00

I have an ItemsControl which has a Canvas as it’s ItemsPanel, the items are

  • 0

I have an ItemsControl which has a Canvas as it’s ItemsPanel, the items are simple Borders, the details of the Borders are databound from a view model, data like X,Y Width, Height, Colour etc. I soon realised that even though I could bind most data like the size and colour to the border item itself I had to bind the point data and ZIndex in the ItemsControl Container Style, I believe this is because these properties pertains only to that ItemContainer which is a ContentPresenter:

<ItemsControl.ItemContainerStyle>
      <Style>
             <Setter Property="Canvas.Left" Value="{Binding Metrics.Ordinate.X}"/>
             <Setter Property="Canvas.Top" Value="{Binding Metrics.Ordinate.Y}"/>
             <Setter Property="Canvas.ZIndex" Value="{Binding ZIndex}"/>
       </Style>
 </ItemsControl.ItemContainerStyle>

Everything has been working as needed up to now. When the user was hovering over the borders I was using a trigger on mouse over to change the background colour but because the UI is already so dependant upon colours we decided that for the hover we wanted the borders to increase in size. So I added a scale transform instead:

 <Trigger Property="IsMouseOver" Value="True">
     <!--<Setter Property="Background" Value="{Binding SelectedTemplate.StandardBrush}"></Setter>-->
         <Setter Property="LayoutTransform">
               <Setter.Value>
                    <ScaleTransform ScaleX="1.5" ScaleY="1.5"/>
                </Setter.Value>
          </Setter>
 </Trigger>

Now the problem is that I need to increase the ZIndex of that single border in the trigger as well so that as it grows it is not clipped by its nearby fellow items. I was searching on how to set the parent item (ContentPresenter) in XAML in a trigger and came across this. That looks perfect except that there is no Name on the content presenter to reference it with, it is a repeated control and I cannot fathom how I can reference it within XAML.

Is this possible within a trigger or am I best looking for a different approach, either one not relying solely upon XAML or maybe a change to my ItemsControl?

Many thanks in advance.

Paul

Edit

Adding the panel template:

 <ItemsControl.ItemsPanel>
            <ItemsPanelTemplate>
                <local:AutoSizeCanvas/>
            </ItemsPanelTemplate>
  </ItemsControl.ItemsPanel>

AutoCanvas is a custom control the derives from Canvas which overrides the measure override so it plays ball living inside a scrollviewer, that is the only difference to a standard Canvas.

Edit

Just to add that I’m using data templates for the bound items as some borders need to contain slightly different items within them, David’s current answer below does work, on mouse over the ZIndex is increased, the problem is that all items that are hovered over have their ZIndex increased so if the mouse goes over an item that is meant to be at the back then it is raised to the top, also this seems very slow. The solution does work but not quite in this scenario as it is doing a blanket setting on all items, not just the one type of border that needs the trigger. In essence I have a seating plan which I get the visual data from another application and have to use it as is. The plan has zones, blocks, rows and seats, It is only the seats that I want this trigger to occur for.

Hope that’s clear.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T05:21:36+00:00Added an answer on May 31, 2026 at 5:21 am

    are you sure that you need the ContentPresenter’s ZIndex to be increased and not just the Border’s ZIndex?

    if so, you do not have many options there. The best I can see is to setup the trigger directly in the itemsPresenter’s style. This way you don’t have to try to find the border’s parent (wich I think is impossible to do just in xaml anyway)

    so you’d end up with something like this:

    <ItemsControl.ItemContainerStyle>
        <Style>
            <Setter Property="Canvas.Left" Value="{Binding Metrics.Ordinate.X}"/>
            <Setter Property="Canvas.Top" Value="{Binding Metrics.Ordinate.Y}"/>
            <Setter Property="Canvas.ZIndex" Value="{Binding ZIndex}"/>
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Canvas.ZIndex" Value="1000"/>
                </Trigger>
            </Style.Triggers>
        </Style>
    </ItemsControl.ItemContainerStyle>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have ItemsControl which I bind to ObservableCollection On my view model I just
I have an items control which has items on a canvas, when I press
I have a View which has a list of items bound to my ViewModel
I have an ItemsControl which is giving me issues. It has a DataTemplate, which
I have a ItemsControl which displays its items in a ScrollViewer , and does
I have an ItemsControl which shows a UserControl as an ItemTemplate. It has a
I have a WPF window which has a ItemsControl which contains list of User
I have an ItemsControl that contains items that each has its own DataTemplate .
I want to have an ItemsControl in which the items are displayed horizontally .
I have a view model called ViewModelClass which contains a boolean. I have another

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.