Follow -up to the answer of this question :Add a Load More Button at the end of ListBox without losing Virtualization?
With this example :
<toolkit:LongListSelector ItemsSource="{Binding Items}">
<toolkit:LongListSelector.ListFooter>
<Grid>
<Button x:Name="btnReadMore" Content="ReadMore"/>
</Grid>
</toolkit:LongListSelector.ListFooter>
Is there a way to change his Content by the C# ? (= "ReadMore" and when the itemsource=0 "go back") thank you !
You can bind the value of the Content property to some ViewModel property. This is the best way IMHO:
You would also bind the Command property to some ViewModel command and this will ensure that you correctly set the caption and handle the result.
But beware, you are not supposed to have a button saying "Go Back" which, when pressed, acts as a hardware back button. You are not supposed to emulate such system functionality.
Related
I want normal cancel functionality on cancel button click of sfdatepicker footer, I am trying to achieve it by binding command but it is not working. Could any one suggest me any solution for that ?
You can use code like below:
<datePicker:SfDatePicker.FooterView>
<Grid>
<Button Text="Ok"
x:Name="footerViewButton"
Clicked="footerViewButton_Clicked"/>
</Grid>
</datePicker:SfDatePicker.FooterView>
Created in this way, and then create the corresponding method in the ViewModel to achieve logical operations.
I have an UWP application with ReactiveUI. I have the following in my DataTemplate:
<MenuFlyoutItem Icon="Edit"
Text="{Binding Resources[EditLabel]}">
Since it is a template, I can't access them in my code behind. So how can I setup the binding here?
I tried the Command but then I can only bind to the item itself and not to the ViewModel of the containing view.
EDIT: I adjusted it that way:
<MenuFlyoutItem Icon="Edit"
Text="{Binding Resources[EditLabel]}"
Command="{Binding DataContext.EditAccountCommand, ElementName=AccountList}"
The Binding does work. I wanted now to add a Converter so I can get the clicked object from the eventargs. But when I add a converter it is executed when the page appears and not when the click is executed. Also I do get the bound command instead of the click arguments.
Greeting,
I'm developing an apps for Windows Phone 8.1 and face some problem with ListView.
I wanted to place a button for the FIRST item in ListView, but it seem like I can't align center the button.
Below is the code I use currently:
<ListView>
<Button Content="Jio!" Height="6" Width="362"/>
<ListViewItem Content="ListViewItem"/>
</ListView>
Adding horizontalalignment='center' just wont work for the button.
The reason I want to do this is because I wanted the button to scroll together with the list, hence I'm placing it inside the ListView.
Please advice what can I do to achieve my purpose, thanks!
I recommend using the ListView.Header content to place such a button instead of adding it as a child directly.
<ListView>
<ListView.Header>
<Button ... HorizontalAlignment="Center" />
</ListView.Header>
</ListView>
By default, the ListViewItems are left-aligned. You will eventually have to replace their Template in order to center-align it (HeaderTemplate Property).
I have a WPF XamDataGrid (I'm using the MVVM pattern, xaml below) and I need it to show the record details in another window when the user double clicks on a row. I have the command which gets the job done, but I don't know how to fire it up as I do with buttons. I want to be able to execute the command when the user double clicks a row, so I need to send the double clicked row (or its ID) as a parameter to the comand. Is it possible?
<igDP:XamDataGrid DataSource="{Binding SomeList}">
<igDP:XamDataGrid.FieldLayoutSettings>
<igDP:FieldLayoutSettings AutoGenerateFields="False"/>
</igDP:XamDataGrid.FieldLayoutSettings>
<igDP:XamDataGrid.FieldLayouts>
<igDP:FieldLayout >
<igDP:FieldLayout.Fields>
<igDP:Field Name="ObjectId" Label="Id" Width="Auto"/>
<igDP:Field Name="Description" Label="Object Description" Width="Auto"/>
</igDP:FieldLayout.Fields>
</igDP:FieldLayout>
</igDP:XamDataGrid.FieldLayouts>
</igDP:XamDataGrid>
I use MVVM pattern too and write such as:
<igDP:XamDataGrid ItemsSource={Binding Path=StaffList, Mode=OneWay}>
...
<igDP:XamDataGrid.InputBindings>
<MouseBinding MouseAction="LeftDoubleClick"
Command="{Binding Path=EditStaffCommand, Mode=OneWay}"
CommandParameter="{Binding Path=DataItem}"/>
</igDP:XamDataGrid.InputBindings>
...
</igDP:XamDataGrid>
Where EditStaffCommand and StaffList - properties from view model
Take a look at Attached command behaviours (http://marlongrech.wordpress.com/2008/12/13/attachedcommandbehavior-v2-aka-acb/). They allow to bind commands to events.
You can create a behavior to add a binding between your ViewModel’s Command and the Double Click event of the Grid.
See the following post for more information:
http://blogs.infragistics.com/forums/p/67749/343013.aspx#343013
i"m using prism with AvalonDoc.
when i try to restore the layout (on the event handler of the menu button "RestoreLayout")
dockManager.RestoreLayout(FileName);
i do get the correct layout structure, but the content of every region is now empty. do i need to reload to modules or something like that ?
the avalondoc code im my xaml code is something like that:
<ad:ResizingPanel ad:ResizingPanel.ResizeWidth="*" Orientation="Vertical" VerticalAlignment="Top">
<ad:DockablePane ad:ResizingPanel.ResizeHeight="150" prism:RegionManager.RegionName="RegionDocPane1">
<ad:DockableContent Name="DocContent1" HorizontalAlignment="Left"/>
</ad:DockablePane>
</ad:ResizingPanel>
<ad:DockableContent Name="DocContent2" HorizontalAlignment="Right"/>
</ad:ResizingPanel>
</ad:DockingManager>
It won't restore your content because Avalon dock (and most docking mechanisms) don't and can't store your user-controls state. You need to do this manually.