c# - Invoking Commands from ListView in MVVM -


I am using the prism for the Windows Runtime so that the events in my scene with the Delayed Commands in my visual models Able to do I'm wondering what would be the best way to run commands (like items, select items) from a list-view with a button (or custom controls generated button button square). I want to keep the effects provided by the button control (such as background change, tilt effect). But the button unfortunately absorbs click events, as a result, I can not use my list in the ListView to hook up, like the following XAML (and Behaviours SDK):

  & lt ; ListView ItemsSource = "{Compulsive Available ItemsList}" SelectionMode = "Single" & gt; & Lt; ListView.ItemTemplate & gt; & Lt; DataTemplate & gt; & Lt; Custom Control: NavMenuButton style = "{StaticResource SelectionListMenuButton}" content = "{binding alias}" descriptiontext = "{binding name}" /> & Lt; / DataTemplate & gt; & Lt; /ListView.ItemTemplate> & Lt; I: Interaction.Behaviors & gt; & Lt; Core: EventTriggerBehavior EventName = "SelectionChanged" & gt; & Lt; Core: InvokeCommandAction command = "{Binding Item Select Command}" /> & Lt; / Core: EventTriggerBehavior & gt; & Lt; / I: Interaction.Behaviors & gt; & Lt; / ListView & gt;   

What would be the best way to achieve this? I have got similar questions, but the difference here is that in the items of the list, the controls apparently "steal" the click event (whereas it works fine with a simple textbox example).

You can use the button within ListView for binding commands in the ListView.

Now to click on the related topic, you see the control template of your button as a simple text block, so your clicks will also be done on the list view and it will not be displayed as a button.

  & lt; Control Template Target Type = "Button" & gt; & Lt; TextBlock Text = "{TemplateBinding Content}" /> & Lt; / ControlTemplate & gt;   

You can also optimize click events in other ways like focusing the button also should lift your click event. This will help in the case of your list view where the command should also be set on by visiting the next item.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -