Click here to Skip to main content
15,916,463 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: scroll based animation in wpf Pin
realhabs21-Aug-15 2:11
realhabs21-Aug-15 2:11 
GeneralRe: scroll based animation in wpf Pin
Pete O'Hanlon21-Aug-15 2:15
mvePete O'Hanlon21-Aug-15 2:15 
Questionhow to defind dynamic column of this table ( ListView ) ? Pin
Yanshof8-Aug-15 4:52
professionalYanshof8-Aug-15 4:52 
QuestionPrevious and Next button Problem Pin
Member 1178652230-Jul-15 3:31
Member 1178652230-Jul-15 3:31 
AnswerRe: Previous and Next button Problem Pin
Richard MacCutchan30-Jul-15 3:54
mveRichard MacCutchan30-Jul-15 3:54 
AnswerRe: Previous and Next button Problem Pin
Pete O'Hanlon30-Jul-15 4:31
mvePete O'Hanlon30-Jul-15 4:31 
GeneralRe: Previous and Next button Problem Pin
Mycroft Holmes30-Jul-15 14:19
professionalMycroft Holmes30-Jul-15 14:19 
Questionhow do i develop 3d photo wall ? Pin
figo.feng28-Jul-15 15:10
figo.feng28-Jul-15 15:10 
GeneralRe: how do i develop 3d photo wall ? Pin
PIEBALDconsult28-Jul-15 15:30
mvePIEBALDconsult28-Jul-15 15:30 
GeneralRe: how do i develop 3d photo wall ? Pin
figo.feng28-Jul-15 17:22
figo.feng28-Jul-15 17:22 
GeneralRe: how do i develop 3d photo wall ? Pin
Richard MacCutchan28-Jul-15 21:09
mveRichard MacCutchan28-Jul-15 21:09 
QuestionSQLite Manager Pin
Kevin Marois22-Jul-15 6:25
professionalKevin Marois22-Jul-15 6:25 
AnswerRe: SQLite Manager Pin
Richard Andrew x6422-Jul-15 6:36
professionalRichard Andrew x6422-Jul-15 6:36 
GeneralRe: SQLite Manager Pin
Kevin Marois22-Jul-15 6:45
professionalKevin Marois22-Jul-15 6:45 
AnswerRe: SQLite Manager Pin
NickPace22-Jul-15 7:44
NickPace22-Jul-15 7:44 
GeneralRe: SQLite Manager Pin
Kevin Marois22-Jul-15 8:02
professionalKevin Marois22-Jul-15 8:02 
GeneralRe: SQLite Manager Pin
Mycroft Holmes22-Jul-15 14:22
professionalMycroft Holmes22-Jul-15 14:22 
GeneralRe: SQLite Manager Pin
Richard MacCutchan22-Jul-15 22:18
mveRichard MacCutchan22-Jul-15 22:18 
AnswerRe: SQLite Manager Pin
Pete O'Hanlon22-Jul-15 22:49
mvePete O'Hanlon22-Jul-15 22:49 
GeneralRe: SQLite Manager Pin
Kevin Marois23-Jul-15 3:50
professionalKevin Marois23-Jul-15 3:50 
QuestionDataBinding to an Icon Pin
Member 1027274820-Jul-15 8:23
Member 1027274820-Jul-15 8:23 
AnswerRe: DataBinding to an Icon Pin
Herman<T>.Instance23-Jul-15 11:31
Herman<T>.Instance23-Jul-15 11:31 
GeneralRe: DataBinding to an Icon Pin
Member 1027274824-Jul-15 1:36
Member 1027274824-Jul-15 1:36 
QuestionWPF Expander - Change Image Pin
Kevin Marois15-Jul-15 6:29
professionalKevin Marois15-Jul-15 6:29 
QuestionCustom Drop Down Menu Button Pin
Kevin Marois7-Jul-15 8:05
professionalKevin Marois7-Jul-15 8:05 
I'm trying to create a Drop Down Button UC. So far it's all going well except that the Content menu has no SelectedItem. So I tried this:

XAML
<Grid x:Name="layoutRoot">

<pre>
<Grid.RowDefinitions>
    <RowDefinition Height="Auto"/>
</Grid.RowDefinitions>

<Button Grid.Row="0" 
        Click="Button_Click">

    <StackPanel Orientation="Horizontal">
        <Image Source="sort_16.png"
                VerticalAlignment="Center"
                Height="16"
                Width="16"/>
        <Image Source="downarrow.png"
                VerticalAlignment="Center"
                Height="3"
                Width="5"/>

    </StackPanel>

    <Button.ContextMenu>
        <ContextMenu/>
    </Button.ContextMenu>

    <Button.Resources>

        <ContextMenu x:Key="menu" ItemsSource="{Binding MenuItems}">

            <ContextMenu.ItemTemplate> 
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">

                        <TextBlock  Text="{Binding Text}"/>
                        <MenuItem  Command="{Binding MenuItemSelectedCommand, Mode=TwoWay}"
                                    CommandParameter="{Binding}"/>

                    </StackPanel>
                </DataTemplate>
            </ContextMenu.ItemTemplate>

        </ContextMenu>

    </Button.Resources>

</Button>




Code behind
public partial class DFTDropDownButton : UserControl
{
    #region Commands
    private ICommand _MenuItemSelectedCommand;
    public ICommand MenuItemSelectedCommand
    {
        get
        {
            if (_MenuItemSelectedCommand == null)
                _MenuItemSelectedCommand = new RelayCommand<DropDownButtonMenuItem>(p => menuItemSelectedExecuted(p), p => menuItemSelectedCanExecute());
            return _MenuItemSelectedCommand;
        }
    }
    #endregion

<pre>
#region MenuItems DP
public List<DropDownButtonMenuItem> MenuItems
{
    get { return (List<DropDownButtonMenuItem>)GetValue(MenuItemsProperty); }
    set { SetValue(MenuItemsProperty, value); }
}

public static readonly DependencyProperty MenuItemsProperty =
DependencyProperty.Register("MenuItems", typeof(List<dropdownbuttonmenuitem>), typeof(DFTDropDownButton), new UIPropertyMetadata(null));
#endregion

#region CTOR
public DFTDropDownButton()
{
InitializeComponent();

this.layoutRoot.DataContext = this;
}
#endregion

#region Private Methods
private bool menuItemSelectedCanExecute()
{
return true;
}

private void menuItemSelectedExecuted(DropDownButtonMenuItem item)
{
}
#endregion

#region Event Handlers
private void Button_Click(object sender, RoutedEventArgs e)
{
Button b = sender as Button;
b.ContextMenu.ItemsSource = MenuItems;
b.ContextMenu.IsOpen = true;
}
#endregion
}


Problem
The Command never fires.

Anyone see what's wrong here?

Thanks
If it's not broken, fix it until it is

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.