How to select all checkBoxes in LongListMultiSelector WP8 - wpf

How can i select all the checkBoxes in LongListMultiSelector on click of a ApplicatonBar's ApplicationBarMenuItem. This feature is same as messaging app of wondows phone.
I reffered
Click here
but no use.
my code:
<toolkit:LongListMultiSelector x:Name="requestList"
EnforceIsSelectionEnabled="False">
<toolkit:LongListMultiSelector.ItemTemplate>
<DataTemplate>
<TextBlock x:Name="requestNameTxtblk"
Text="{Binding request}"
TextWrapping="Wrap" HorizontalAlignment="Left"
Width="268" Height="66" FontSize="25"/>
</DataTemplate>
</toolkit:LongListMultiSelector.ItemTemplate>
</toolkit:LongListMultiSelector>
Thanks

Can you just iterate over the requestList's ItemsSource and mark the items as selected:
(note this code is not tested, just a guess for now):
foreach (var item in requestList.ItemsSource)
{
item.Selected = true;
}
Or similar?

Hi guys got the solution
foreach (var item in requestList.ItemsSource)
{
requestList.SelectedItems.Add(item);
}
this will check all the checkBox in the list and to uncheck all the box
Remove() method can be used as add()

Related

Get content of Checkbox with Hyperlink as content

This is an example of how I make my checkboxes:
<CheckBox x:Name="Ekm" Checked="Check" Unchecked="UnCheck">
<CheckBox.Content>
<TextBlock>
<Hyperlink RequestNavigate="Hyperlink_RequestNavigate" NavigateUri="[REDACTED]">
Banking History
</Hyperlink>
</TextBlock>
</CheckBox.Content>
</CheckBox>
And the code-behind:
foreach (var checkbox in listview.Items)
{
if (checkbox is CheckBox cb)
{
if (cb.Name.StartsWith("Sa"))
{
SelectAllCheckBoxes.Add(cb);
}
else
{
AllCheckBoxes.Add(cb);
}
}
}
And the moment I try to read the content (Specifically the words "Banking History"):
foreach (var cb in AllCheckBoxes)
{
NameCompareTuples.Add(new Tuple<string, string>(cb.Name, cb.Content.ToString()));
}
The above code, and many variations I've tried (Casting as TextBlocks and such, thus not needing ".ToString();"), simply return an empty string, or if I apply ".ToString();" it passes something along the lines of:
"System.Windows.Controls.TextBlock"

SAPUI5 JSONModel cant be updated in controler

i have 2 Comboboxes on my view.xml. If one changes his content, the other should apear.
<ComboBox id="cb1_ort_anla" width="100%" selectionChange="selChange" value="{/item/value1}" selectedKey="1">
..
</ComboBox>
<ComboBox id="cb2_oa" width="100%" selectionChange="onChange" value="{/item/value2}" selectedKey="1" visible="{/visibility_loc_sub}">
</ComboBox>
In the controler, i am defining a model with the properties from above:
onInit : function (){
this.oModel = new JSONModel(
{ "visibility_loc_sub" : false,
"visibility_asset" : true,
"item":{
"value1":"",
"value2":"",
"value3":""
}
});
this.getView().setModel(this.oModel);
}
the methode selChange should change the property "visibility_loc_sub" to true with this code:
selChange : function(oEvent){
this.oModel.setProperty("visibility_loc_sub", true);
this.getView().setModel(this.oModel);
} <--
In the debugger the property visibility_loc_sub at this(<--) point is still false. "this.oModel.visibility_loc_sub= true;" is not working either.
Am i doing something wrong? And if yes, what should i do?
thanks for your help!

F# wpf async command completion status

I've been experimenting with async commands using F# Viewmodule. The problem is when I click the button, the command get executed, but afterwards the button stays disabled.
Xaml:
<Button Content="start async worker" Command="{Binding StartAsyncCommand}" />
ViewModel:
type MainViewModel() as me =
inherit ViewModelBase()
//...
member __.StartAsyncCommand = me.Factory.CommandAsync(fun _ -> async { return () } )
What am I doing wrong?
EDIT:
Thanks to #FoggyFinder, we determined that the issue was actually with the App.fs file:
open System
open FsXaml
open System.Windows
type MainWindow = XAML< "MainWindow.xaml">
[<STAThread>]
[<EntryPoint>]
let main argv =
Application().Run(MainWindow().Root)
Creating basically empty App.xaml and starting like this:
module main
open System
open FsXaml
type App = XAML<"App.xaml">
[<STAThread>]
[<EntryPoint>]
let main argv =
App().Root.Run()
fixed it. If anyone knows the explanation for this, don't hesitate to provide it.
What am I doing wrong?
The problem is that there is no SynchronizationContext in place when you construct your ViewModel layer, which means that the internal code that pushes things back to the UI context don't work properly.
You can work around this by adding the following at the beginning of your entry point, before you call Application.Run():
if SynchronizationContext.Current = null then
DispatcherSynchronizationContext(Dispatcher.CurrentDispatcher)
|> SynchronizationContext.SetSynchronizationContext
This will make sure the Dispatcher is created and a valid SynchronizationContext is installed, and will likely fix the issue for you.
I used asynchronous commands, but this problem never arose. I tried to reproduce your code - everything is working fine. Are you sure you gave complete code?
Try to run the code:
.xaml:
<Window.DataContext>
<local:MainViewModel/>
</Window.DataContext>
<Grid>
<Button Content="start async worker" Command="{Binding StartAsyncCommand}" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="5" />
<TextBlock Text="{Binding Count}" Margin="5" HorizontalAlignment="Right" VerticalAlignment="Top"></TextBlock>
</Grid>
ViewModel:
type MainViewModel() as me =
inherit ViewModelBase()
let count = me.Factory.Backing(<# me.Count #>, 0)
member __.StartAsyncCommand = me.Factory.CommandAsync(fun _ -> async { count.Value <- count.Value + 1 })
member __.Count with get() = count.Value
About the differences between
let dosomething _ = async { return () }
member __.StartAsyncCommand = me.Factory.CommandAsync(dosomething)
and :
member __.StartAsyncCommand = me.Factory.CommandAsync(fun _ -> async { return () } )
look this answer:
https://chat.stackoverflow.com/transcript/message/26511092#26511092
The easy workaround is to use interaction triggers:
<Button>
<ia:Interaction.Triggers>
<ia:EventTrigger EventName="Click">
<fsx:EventToCommand Command="{Binding StartAsyncCommand}" />
</ia:EventTrigger>
</ia:Interaction.Triggers>
</Button>

InteractionRequest CustomPopupWindow does not resize

Using a prism Interactionrequest together with a CustomPopUpWindow I have the Problem, that the custom popup window does not resize.
Calling the interaction the first time, it sizes its self to the content correctly, but if I call it again, it kind of memorizes this size and does not change size according to its changed content.
Is this a known issue, or am I doing things wrong?
Regards
Rainer
<i:Interaction.Triggers>
<InteractionRequest:InteractionRequestTrigger SourceObject="{Binding ImportConfirmation, Mode=OneWay}">
<InteractionRequest:PopupWindowAction IsModal="True" CenterOverAssociatedObject="True">
<InteractionRequest:PopupWindowAction.WindowContent>
<Views:ImportMachineDefintionConfirmationView/>
</InteractionRequest:PopupWindowAction.WindowContent>
</InteractionRequest:PopupWindowAction>
</InteractionRequest:InteractionRequestTrigger>
<InteractionRequest:InteractionRequestTrigger SourceObject="{Binding DeleteMachineDefinitionConfirmation, Mode=OneWay}">
<InteractionRequest:PopupWindowAction IsModal="True" CenterOverAssociatedObject="True" >
<InteractionRequest:PopupWindowAction.WindowContent>
<Views:DeleteMachineDefinitionConfirmationView/>
</InteractionRequest:PopupWindowAction.WindowContent>
</InteractionRequest:PopupWindowAction>
</InteractionRequest:InteractionRequestTrigger>
</i:Interaction.Triggers>
private void DeleteMachineDefinitionCommandExecute(IVersionAwareMachineDefinition machineDefinition)
{
var deleteConfirmation =
this.unityContainer.Resolve<IDeleteMachineDefinitionConfirmationViewModel>(
new ParameterOverride("machineDefinitionToDelete", machineDefinition));
this.DeleteMachineDefinitionConfirmation.Raise(
deleteConfirmation,
_ =>
{
if (!_.Confirmed)
{
return;
}
this.repository.DeleteMachineDefinition((MachineType)machineDefinition.MachineTypeId, machineDefinition.MachineNumber);
this.MachineDefinitions =
new ObservableCollection<IVersionAwareMachineDefinition>(this.repository.GetKnownVersionAwareMachineDefinitions());
this.SelectedMachineDefinition = null;
});
}

Show multiple items selected within combobox in Silverlight when do key navigation in edit mode without dropdown open

Just bind ItemSource to Silverlight ComboBox. Do key navigation within a combobox where DropDown should not be opened. after completing key navigation click drop down icon to view the drop down list. There are multiple items selected that has same value, some times different value selected.
Is there any way to overcome this issue ? Or is that framework issue?
Details:
My combobox xaml is here:
<ComboBox ItemsSource="{Binding Path=ComboBoxItemsSource}" Grid.Column="1" Width="150" Height="40"/>
where ComboBoxItemsSource is List of String collection that defined in ViewModel.
ViewModel
string[] productName = new string[]
{
"Alice Mutton",
"NuNuCa Nuß-Nougat-Creme",
"Boston Crab Meat",
"Raclette Courdavault",
"Wimmers gute Semmelknödel",
"Gorgonzola Telino",
"Chartreuse verte",
"Fløtemysost",
"Carnarvon Tigers",
"Thüringer Rostbratwurst",
"Vegie-spread",
"Tarte au sucre",
"Konbu",
"Valkoinen suklaa",
"Queso Manchego La Pastora",
"Perth Pasties",
"Vegie-spread",
"Tofu",
"Sir Rodney's Scone 7",
"Manjimup Dried Apples"
};
private List<string> _comboBoxItemsSource = new List<string>();
public List<string> ComboBoxItemsSource
{
get { return _comboBoxItemsSource; }
set { _comboBoxItemsSource = value; }
}
public ViewModel()
{
_comboBoxItemsSource = productName.ToList();
}
The Setting should be Button, ComboBox.
First get focus on Button.
Then press tab to focus combo box.
Now, Just do pressing - right/left/up/down keys continuously.
Now click on drop down icon. you can see that multiple items
selected.

Resources