Click here to Skip to main content
15,881,715 members
Home / Discussions / WPF
   

WPF

 
QuestionCommand Binding In User Control Pin
Kevin Marois9-Jun-17 12:24
professionalKevin Marois9-Jun-17 12:24 
AnswerRe: Command Binding In User Control Pin
Pete O'Hanlon9-Jun-17 21:26
mvePete O'Hanlon9-Jun-17 21:26 
GeneralRe: Command Binding In User Control Pin
Kevin Marois12-Jun-17 5:01
professionalKevin Marois12-Jun-17 5:01 
QuestionStyle User Control Pin
Kevin Marois22-May-17 5:19
professionalKevin Marois22-May-17 5:19 
AnswerRe: Style User Control Pin
eddieangel15-Sep-17 10:28
eddieangel15-Sep-17 10:28 
QuestionBind ColumnGroup text Pin
Mycroft Holmes18-May-17 16:01
professionalMycroft Holmes18-May-17 16:01 
AnswerRe: Bind ColumnGroup text (Resolved) Pin
Mycroft Holmes23-May-17 22:47
professionalMycroft Holmes23-May-17 22:47 
QuestionCustom SplitButton Control Styling Pin
Kevin Marois18-May-17 10:24
professionalKevin Marois18-May-17 10:24 
I have created a split button that looks and works like one of these. I put it up OneDrive.

I've never really done anything like this before, and I'd like to create a suite of controls. I've already created a DropDown Date/Time Picker. Now I have this done.

So for this control, use it like this:
xmlns:sb="clr-namespace:Marois.Framework.WPF.Controls.SplitButtonControl;assembly=Marois.Framework.WPF.Controls"
<sb:SplitButton Grid.Column="5"
                Height="25"
                Width="150"
                Items="{Binding ElementName=myWindow, Path=MyItems}"
                SelectedItem="{Binding ElementName=myWindow, Path=MySelectedItem, Mode=TwoWay}"
                SelectedItemChanged="SplitButton_SelectedItemChanged" />

and in the code behind
public partial class MainWindow : Window, INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;

    private List _MyItems;
    public List MyItems
    {
        get { return _MyItems; }
        set
        {
            if (_MyItems != value)
            {
                _MyItems = value;
                RaisePropertyChanged("MyItems");
            }
        }
    }

    private SplitButtonItem _MySelectedItem;
    public SplitButtonItem MySelectedItem
    {
        get { return _MySelectedItem; }
        set
        {
            if (_MySelectedItem != value)
            {
                _MySelectedItem = value;
                RaisePropertyChanged("MySelectedItem");
            }
        }
    }

    public MainWindow()
    {
        InitializeComponent();

        this.DataContext = this;

        MyItems = new List
        {
            new SplitButtonItem(new BitmapImage(new Uri(@"left_arrow.png")), "Item 1"),
            new SplitButtonItem(null, "Item 2"),
            new SplitButtonItem(new BitmapImage(new Uri(@"right_arrow.png")), "Item 3"),
        };
    }

    protected void RaisePropertyChanged(string propertyName)
    {
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
    }

    private void SplitButton_SelectedItemChanged(object sender, SplitButtonControl.SplitButton.SelectionChangedEventArgs e)
    {
        MessageBox.Show(e.SelectedItem.Caption, "Selected Item", MessageBoxButton.OK, MessageBoxImage.Information);
    }
}

So here's the question. If you look at the XAML for the control you'll see two Templates - one for the Button portion and another for the ToggleButton. They contain various settings for colors, brushes, margins, CornerRadius, etc.

How do you create a style for this? Would you name each element and then create a style that targets each named element?

How do you create a suite of controls, then create style(s) that apply across all your controls?

Thanks!
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.

QuestionRe: Custom SplitButton Control Styling Pin
Gerry Schmitz18-May-17 11:34
mveGerry Schmitz18-May-17 11:34 
AnswerRe: Custom SplitButton Control Styling Pin
Kevin Marois18-May-17 12:37
professionalKevin Marois18-May-17 12:37 
GeneralRe: Custom SplitButton Control Styling Pin
Gerry Schmitz18-May-17 12:55
mveGerry Schmitz18-May-17 12:55 
GeneralRe: Custom SplitButton Control Styling Pin
Kevin Marois18-May-17 19:03
professionalKevin Marois18-May-17 19:03 
GeneralRe: Custom SplitButton Control Styling Pin
Gerry Schmitz18-May-17 19:37
mveGerry Schmitz18-May-17 19:37 
GeneralRe: Custom SplitButton Control Styling Pin
Kevin Marois19-May-17 5:04
professionalKevin Marois19-May-17 5:04 
GeneralRe: Custom SplitButton Control Styling Pin
Gerry Schmitz19-May-17 5:33
mveGerry Schmitz19-May-17 5:33 
GeneralRe: Custom SplitButton Control Styling Pin
Kevin Marois22-May-17 5:23
professionalKevin Marois22-May-17 5:23 
GeneralRe: Custom SplitButton Control Styling Pin
Gerry Schmitz22-May-17 6:15
mveGerry Schmitz22-May-17 6:15 
GeneralRe: Custom SplitButton Control Styling Pin
Gerry Schmitz22-May-17 6:35
mveGerry Schmitz22-May-17 6:35 
GeneralRe: Custom SplitButton Control Styling Pin
Kevin Marois22-May-17 6:50
professionalKevin Marois22-May-17 6:50 
GeneralRe: Custom SplitButton Control Styling Pin
Gerry Schmitz22-May-17 7:07
mveGerry Schmitz22-May-17 7:07 
QuestionTheming Question Pin
Kevin Marois5-May-17 7:29
professionalKevin Marois5-May-17 7:29 
QuestionWPF MVVM ListView Bound to ObservableCollection doesnt update after i make changes Pin
Member 1288059527-Apr-17 7:25
Member 1288059527-Apr-17 7:25 
AnswerRe: WPF MVVM ListView Bound to ObservableCollection doesnt update after i make changes Pin
Richard Deeming27-Apr-17 8:26
mveRichard Deeming27-Apr-17 8:26 
GeneralRe: WPF MVVM ListView Bound to ObservableCollection doesnt update after i make changes Pin
Member 1288059527-Apr-17 9:02
Member 1288059527-Apr-17 9:02 
GeneralRe: WPF MVVM ListView Bound to ObservableCollection doesnt update after i make changes Pin
Member 1288059528-Apr-17 10:12
Member 1288059528-Apr-17 10:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.