GridView-like page but with static groups and each group section will have a different layout - windows-8

I would like to create a page a little like the Grouped Items Page inside the Contoso Cookbook application (if you have seen it). Basically, it's a GridView bound to a CollectionViewSource.
<CollectionViewSource
x:Name="groupedItemsViewSource"
Source="{Binding Groups}"
IsSourceGrouped="true"
ItemsPath="TopItems"
d:Source="{Binding AllGroups, Source={d:DesignInstance Type=data:SampleDataSource, IsDesignTimeCreatable=True}}"/>
The GridView appears to bind the Groups to the highest level of the CVS data source with the Source attribute and then binds each individual section with the ItemsPath attribute.
However, my page differs in that my groups are static, they are: Times, Categories, List. The first will have a listview, the second a grid of tiles and the third will be another listview.
Also, each group section itself has a different layout. It's not just repeating groups and repeating item-layouts. I was expecting to be able to define "static" groups and a layout for each group directly in the XAML and maybe even add test data to those elements, but it seems like GridView requires data binding, even if just to a dummy data source at design time.
So how would you do this? So essentially, it needs exactly the same horizontal scroll and wrapping as the GridView, but the groups have totally different layouts and each group should ideally be definable directly in the XAML?
I'm thinking of creating a normal grid enclosed in a scroll viewer... what do you think? What would you do?

In a GridView, groups can be assigned a GroupStyle like this:
<GridView.GroupStyle>
<GroupStyle HeaderTemplate="{StaticResource MyGroupHeaderTemplate}"
Panel="{StaticResource MyGroupItemsPanelTemplate}"
HidesIfEmpty="True" />
</GridView.GroupStyle>
Now, in your case each group will need its own GroupStyle.
So instead of using a ListView within each group in a GridView, you could:
Define 2 different group styles with header templates and the panel (ItemsPanelTemplate (MSDN)) that you want to use
Define a class that has your custom logic to select which group style to use for a group.(GroupStyleSelector)
Set the GroupStyleSelector property on the GridView in XAML
Define static groups in your view model to contain the data you want: (Times, Categories, List)

This can be accomplished with a DataTemplateSelector. You would have multiple groups, but within each group the items are styled differently. See this SO post for more help articles.

Related

How to loop for each record in One2Many field in form view to create dynamic elements?

I have a customized One2Many field that contains several records for this current data.
I am working on a form view.
I need to construct something like this: (I don't want a tree)
<for every record in one2many_field>
<button something...>
</for>
I only want the result as to create 1 button per record in the one2many_field and be able to get the data in some fields from the model of the one2many_field too.
Is there any way to achieve it? I have searched for some time but found nothing even remotely close to this requirement.
You won't be able to achieve that in a Form View. Views in Odoo are kind of strict but it's mostly to avoid bad stuff to happen.
Anyway, you could think about re-creating the full view by yourself using QWeb View (doc for v14 here)
If you want to keep your Form View, you'll have to use a tree inside the form.
Know that you can totally add buttons in Tree views like adding on a sale.order.line something like <button class="btn btn-primary" type="object" name="product_id_change" string="Force Product Id Change"/> (useless, just for the example)
Check example image here
And play with some attrs to change the visibility of fields...
Hope it helped :)

How to dynamically filter a PXSelect property based on a form field

I want to filter related POReceipts if a PONumber is selected. If no PONumber is selected, I want to show all POReceipts.
A POOrder has many POReceipts
In my graph, I have the following
Data Source
public PXSelect<MYGRPH> Document;
I want the following property to be able to be dynamically filtered based on PO Number....
public PXSelect<POReceipt, Where<POReceit.status, Equal<POStatus.open>>> Receipts]
How can I dynamically filter 'Receipts' to add the following clause, if a PO number is filled in?
Where<POReceipt.orderNbr, Equal<Current<MYGRAPH.orderNbr>>> ??
Is there a way to dynamically add a restrictor?
Make a view on POOrder:
PXSelect<POOrder> Document;
In the Form add controls for POOrder key fields:
<px:PXDropDown CommitChanges="True" ID="edOrderType" runat="server" AllowNull="False" DataField="OrderType" SelectedIndex="2" />
<px:PXSelector CommitChanges="True" ID="edOrderNbr" runat="server" DataField="OrderNbr" AutoRefresh="True" />
When the user selects the POOrder key fields in the form control it sets the current POOrder cache object and you can use that to filter the other view:
public PXSelectJoin<POReceipt,
LeftJoin<POOrderReceipt, On<POReceipt.receiptNbr, Equal<POOrderReceipt.receiptNbr>>>,
Where<POOrderReceipt.pOType, Equal<Current<POOrder.orderType>>,
And<POOrderReceipt.pONbr, Equal<Current<POOrder.orderNbr>>>>> Receipts;
EDIT:
The problem is, that the POOrder field will not always be filled in
first.
Add Or clauses as Brendan suggested in the comments:
public PXSelectJoin<POReceipt,
LeftJoin<POOrderReceipt, On<POReceipt.receiptNbr, Equal<POOrderReceipt.receiptNbr>>>,
Where<Where2<Where<Current<POOrder.orderType>, IsNull,
Or<Current<POOrder.orderType>, Equal<POOrderReceipt.pOType>>>,
And<Where2<Where<Current<POOrderReceipt.pONbr>, IsNull>,
Or<Current<POOrderReceipt.pONbr>, Equal<POOrder.orderNbr>>>>>>> Receipts;

How to format label in Xamarin XAML Listview based on a viewmodel attribute

I am trying to create a ListView cell data template with a label that shows either a "detailed" description or a "short" description based on whether another variable ViewLevel is "Detailed" or "Short".
I am using an IValueConverter and trying to bind the ConverterParameter, but that does not work as I don't think the ConverterParameter is bindable.
Is there a best practice for doing this?
The label I currently have is:
<Label Binding Options, Converter={viewModels:DetailLabelConverter}, ConverterParameter='Detail'}" />
It works, but obviously has the hardcoded Detail view. I've also tried:
<Label Text="{Binding Options, Converter={viewModels:DetailLabelConverter}, ConverterParameter={Binding Source={x:Reference BasePage}, Path=BindingContext.ViewLevel}}"/>
Which works, insomuch as it calls the DetailLabelConverter. Unfortunately the parameter is not loaded with the value of ViewLevel but a Xamarin.Forms.Binding object.
It seems like this should be a fairly common pattern but I can't find a reasonable solution.

C# Windows Store App - Find resource on xaml

If i have 9 TextBlock declared on the XAML file like this:
<TextBlock Name="cellText_00" Tag="0"/>
<TextBlock Name="cellText_01" Tag="1"/>
<TextBlock Name="cellText_02" Tag="2"/>
<TextBlock Name="cellText_20" Tag="3"/>
...
<TextBlock Name="cellText_22" Tag="8"/>
There is a way to interact with it from the .cs getting exactly the desired tag element?
For instance is it possible to give all the same name and get it in this way:
TextBlock tb = get(cellText,0);
where the first field is the name and the second one is the tag?
No, you can't use the same name for many controls.
However there is a workaround: using the FindName method:
http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.findname(v=vs.95).aspx
There Why can't I access a TextBox by Name with FindName()?
you can find an example and a solution related to namespaces issues.
FindName uses a string to retrieve the control. So you can do something like this: FindName("cellText_" + identifier); and take the element you need.
#Sandrouos, I don't think he's using the same name.
This blogpost explains it perfectly:
http://blog.jerrynixon.com/2012/09/how-to-access-named-control-inside-xaml.html

XAML for floating window in AvalonDock

Can someone provide me with an AvalonDock XAML code piece that when run opens the app with a floating window instead of being always docked inside the dock pane? I've seen programmatic ways to do it, but I thought there must be a way to specify it in XAML. Thanks...
I know this is a bit late, but hopefully it will help someone with the same issue in the future...
To create a floating document, add a LayoutDocumentFloatingWindow as a child of LayoutDocumentFloatingWindow, and then add your LayoutDocument as a child of the LayoutDocumentFloatingWindow, as below:
<xcad:DockingManager>
<xcad:LayoutRoot>
<xcad:LayoutRoot.FloatingWindows>
<xcad:LayoutDocumentFloatingWindow>
<xcad:LayoutDocument Title="My Document">
<!--Add document content here-->
</xcad:LayoutDocument>
</xcad:LayoutDocumentFloatingWindow>
</xcad:LayoutRoot.FloatingWindows>
</xcad:LayoutRoot>
</xcad:DockingManager>
Similarly you can add anchorables like so:
<xcad:DockingManager>
<xcad:LayoutRoot>
<xcad:LayoutRoot.FloatingWindows>
<xcad:LayoutAnchorableFloatingWindow>
<xcad:LayoutAnchorablePaneGroup>
<xcad:LayoutAnchorablePane>
<xcad:LayoutAnchorable Title="My anchorable">
<!--Add anchorable content here-->
</xcad:LayoutAnchorable>
</xcad:LayoutAnchorablePane>
</xcad:LayoutAnchorablePaneGroup>
</xcad:LayoutAnchorableFloatingWindow>
</xcad:LayoutRoot.FloatingWindows>
</xcad:LayoutRoot>
Note that unlike LayoutDocuments, for anchorables you need to add a group pane rather than just a single LayoutAnchorable, because floating anchorables are designed to be able to be grouped in a single window but LayoutDocuments are not.
As a more general guide, an example of how to set up varioius layout elements in a DockingManager can be found here: https://xceed.com/wp-content/documentation/xceed-toolkit-plus-for-wpf/AvalonDock.html