简体   繁体   中英

Custom Control or Slider like Control

What i am basically looking out for is a combination of controls that work as 1 whole. I have no idea what the best way would be to start solving this problem in WPF, either a custom control, existing control, slider...?

Only thing i do not want are 3th party controls and the such.

When a certain condition is met a button with text will be placed inside the slider. Every time when certain conditions are met this situation will keep on happening and buttons will be placed inside the border field.

So it could be possible i have like 10 buttons after each other inside the border. The 2 navigation buttons to the left and right serve as navigation between all those buttons so all can actually get view and pressed when needed for further actions.

Picture that illustrates what i wish to achieve:

范例图片

You can start with something simple as a StackPanel (you dont need to put it in a page but i wanted to make it copy paste friendly):

<Page
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <StackPanel>
    <Button Content="Left"/>
    <ListBox>
      <ListBoxItem>btnTest 10:00h</ListBoxItem>
      <ListBoxItem>btnTest 11:00h</ListBoxItem>
    </ListBox>
    <Button Content="Right"/>
  </StackPanel>
</Page>

Then focus on the appearance and behavior separately.

  1. You need to learn WPF styles, so you can get the colors and layout as in your sample picture. This will also let you make the ListBox horizontal.
  2. Look into the concept of a ViewModel to learn how to populate the ListBox with items. And event handlers for the buttons.

Its a very broad question but I hope this gives you a start.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM