-
- Andreas Schooll
- Posts: 25
- Joined:
ListView / ListBox with a Button in each Line
Hi there,
we have several cases in our UI design, where we have a Button in each line of a ListView or ListBox. In example a delete Button to Delete something associated with the line.
I found a good example how this is normally done in XAML / WPF:
http://stackoverflow.com/questions/7127 ... -each-line
I read in the forums that
<Button Click="Button_Click">X</Button>
will currently not work with Noesis and Unity. Is that a fact?
What would be a good workaround to achieve our goal?
best regards,
Andreas
we have several cases in our UI design, where we have a Button in each line of a ListView or ListBox. In example a delete Button to Delete something associated with the line.
I found a good example how this is normally done in XAML / WPF:
http://stackoverflow.com/questions/7127 ... -each-line
I read in the forums that
<Button Click="Button_Click">X</Button>
will currently not work with Noesis and Unity. Is that a fact?
What would be a good workaround to achieve our goal?
best regards,
Andreas
-
- golgepapaz
- Posts: 43
- Joined:
Re: ListView / ListBox with a Button in each Line
if you know the button name there is a example to how to register click callbacks to a button at runtime.
viewtopic.php?f=3&t=156
viewtopic.php?f=3&t=156
-
-
sfernandez
Site Admin
- Posts: 3203
- Joined:
Re: ListView / ListBox with a Button in each Line
A good way to implement what you need is by using commands.
- The class that describes your items will expose a property for each command you need: EditItemCommand, DeleteItemCommand, ... (like the DelegateCommand we exposed in our Commands sample in NoesisGUI package).
- Then your DataTemplate will include a Button for each command you want to execute binded to the corresponding item's command property, for example:
But other user reported a bug about this scenario that needs to be solved before you can do it that way. We will let you know when it is fixed.
Sorry for the inconvenience
- The class that describes your items will expose a property for each command you need: EditItemCommand, DeleteItemCommand, ... (like the DelegateCommand we exposed in our Commands sample in NoesisGUI package).
- Then your DataTemplate will include a Button for each command you want to execute binded to the corresponding item's command property, for example:
Code: Select all
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding ItemName}"/>
<Button Content="Edit" Command="{Binding ItemEditCommand}"/>
<Button Content="Delete" Command="{Binding ItemDeleteCommand}"/>
</StackPanel>
</DataTemplate>
Sorry for the inconvenience

-
- Andreas Schooll
- Posts: 25
- Joined:
Re: ListView / ListBox with a Button in each Line
Hey, thanks for your replies.
@golgepapaz:
We also thought about installing the click-function manually. But as the listitems get created manually we would need some kind of callback to access those list elements to get to the buttons. Or iterate through all elements after something in the list changes. But i don't know if this is a reasonable approach?
@sfernandez
Do you think this will be fixed within the next 2 weeks?
Would it work if we created a UserControl for a listelement that has its own xaml and c# code. In the c# code we could easily access the button. Do ListViews work with UserControls in the Datatempalte?
best regards,
Andreas
@golgepapaz:
We also thought about installing the click-function manually. But as the listitems get created manually we would need some kind of callback to access those list elements to get to the buttons. Or iterate through all elements after something in the list changes. But i don't know if this is a reasonable approach?
@sfernandez
Do you think this will be fixed within the next 2 weeks?
Would it work if we created a UserControl for a listelement that has its own xaml and c# code. In the c# code we could easily access the button. Do ListViews work with UserControls in the Datatempalte?
best regards,
Andreas
Re: ListView / ListBox with a Button in each Line
Yes, at least it is planned.@sfernandez
Do you think this will be fixed within the next 2 weeks?
Who is online
Users browsing this forum: Semrush [Bot] and 2 guests