-1

This Model

public class Media
{
    private List<string> mediaName;

    public List<string> MediaName
    {
        get { return mediaName; }
        set { mediaName = value; }
    }

}

this xaml Code

<ComboBox x:Name="MediaCombo" ItemsSource="{Binding Media}" SelectionChanged="MediaCombo_SelectionChanged">
  <ComboBox.ItemTemplate>
    <DataTemplate>
     <TextBlock Text="{Binding}" />
    </DataTemplate>
  </ComboBox.ItemTemplate>

I can't find way, contextmenu.. combobox... etc.. How to i

how to Make like picture? Combobox Image

Community
  • 1
  • 1

1 Answers1

0

Welcome to SO!

Don't be surprised if this question gets flagged for closure, this site is for answers to very specific questions rather than "how do I do this?"

To get you started though, you'll need to template your control to replace the default appearance. If you place your edit cursor over the ComboBox declaration in the XAML, go to the properties page, click the little box to the right of Miscellaneous->Template then select "Convert to new resource" then VS will template the control out for you. (In the case of ComboBox you'll probably also need to add a project reference to PresentationFramework.Aero2).

The control template that gets created will have a ScrollViewer in it with x:Name="DropDownScrollViewer", so repeat this process on that to template out that element into a new template called ScrollViewerControlTemplate1. That will have a control for the actual vertical scrollbar with x:Name="PART_VerticalScrollBar", so repeat yet again to get a final control template called ScrollBarControlTemplate1. This is the scrollbar you want to change the appearence of, so you can simply override the content of that to get the effect you're after e.g.:

    <ControlTemplate x:Key="ScrollBarControlTemplate1" TargetType="{x:Type ScrollBar}">
        <Border BorderBrush="{DynamicResource VS.Environment.ScrollBarBorderBrush}" Uid="Border_3" Padding="5">
            <Grid Uid="Grid_1">
                <Border BorderThickness="1" BorderBrush="Gray" CornerRadius="5"/>
                <Track x:Name="PART_Track" IsDirectionReversed="True" Uid="PART_Track">
                    <Track.Thumb>
                        <Thumb Uid="Thumb_1">
                            <Thumb.Template>
                                <ControlTemplate>
                                    <Border Background="Gray" CornerRadius="5"/>
                                </ControlTemplate>
                            </Thumb.Template>
                        </Thumb>
                    </Track.Thumb>
                </Track>
            </Grid>
        </Border>
    </ControlTemplate>

...which will result in this:

enter image description here

I haven't done the paging buttons, but it's basically the same idea. Look for the elements of type RepeatButton in the original ScrollBarControlTemplate1 that gets created (which I removed) and place them in the ScrollViewerControlTemplate1 instead below the ScrollContentPresenter which contains the list elements themselves.

Mark Feldman
  • 15,731
  • 3
  • 31
  • 58
  • How to apply template – company CHOI Mar 16 '20 at 14:48
  • VS will do it for you automatically, but it's done by simply setting the template property i.e. `Template="{StaticResource theResourceTemplateKey}"`. – Mark Feldman Mar 16 '20 at 22:44
  • It's Done!. Thank you. But how can you create an image-like style? Do you know the image collection site? Uid, IsDirection Reversed, Thumb, and so on. I've never seen them before. – company CHOI Mar 17 '20 at 01:39
  • Sorry, I'm not sure I follow you. All of those things are dependency properties of the `Track` control. You can make your own custom `UserControls`, and you can give them their own dependency properties just like any other control. Pretty much everything you need is on the MSDN site (including [the documentation for dependency properties](https://learn.microsoft.com/en-us/dotnet/framework/wpf/advanced/dependency-properties-overview)), and of course there are also plenty of [tutorials around the net](https://www.informit.com/articles/article.aspx?p=2115888&seqNum=3). – Mark Feldman Mar 17 '20 at 10:10