I'm trying to add a custom Scroller.as (extended from spark.components.Scroller) to a InfiniteScrollList.as (extended from spark.components.list)
I wrote the following MXML code:
<list:InfiniteScrollList width="100%" height="100%" id="EventsList" useVirtualLayout="true">
<list:scroller>
<list:Scroller/> <!-- The Scroller.as Class -->
</list:scroller>
</list:InfiniteScrollList>
The List behavior works well but the extended Scroller component does not function at all.
What is the correct way to add this scroller functionality (in MXML or ActionScript) to the list?
The s:Scroller is used by wrapping it around the content or DataGroup. But the List class wraps all that functionality inside of it's skin, so I believe that in order to create a custom Scroller for a List, you actually need to do within the SkinClass.
<list:InfiniteScrollList width="100%" height="100%" id="EventsList"
useVirtualLayout="true" skinClass="MyListSkin" />
MyListSkin.mxml:
<s:SparkSkin xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:fb="http://ns.adobe.com/flashbuilder/2009" minWidth="112">
<fx:Metadata>
[HostComponent("spark.components.Scroller")]
</fx:Metadata>
<s:states>
<s:State name="normal" />
<s:State name="disabled" />
</s:states>
<!-- The Scroller.as Class -->
<list:Scroller left="0" top="0" right="0" bottom="0" id="scroller" hasFocusableChildren="false">
<!--- #copy spark.components.SkinnableDataContainer#dataGroup -->
<s:DataGroup id="dataGroup" itemRenderer="spark.skins.spark.DefaultItemRenderer">
<s:layout>
<!--- The default layout is vertical and measures at least for 5 rows.
When switching to a different layout, HorizontalLayout for example,
make sure to adjust the minWidth, minHeight sizes of the skin -->
<s:VerticalLayout gap="0" horizontalAlign="contentJustify" requestedMinRowCount="5" />
</s:layout>
</s:DataGroup>
</list:Scroller/>
</s:SparkSkin>
Related
I want to implement a ListView that loads new content when is scrolled (it will have over 2000 elements) with a scrollbar. This is what I have:
<ListView
Width="500"
MaxHeight="400"
IsItemClickEnabled = "False"
SelectionMode ="None"
IncrementalLoadingThreshold="5"
IncrementalLoadingTrigger="Edge"
ScrollViewer.VerticalScrollBarVisibility="Visible"
ScrollViewer.VerticalScrollMode="Enabled"/>
The list works perfectly fine but the scrollbar is not visible. How can I make it work?
there is another way to go.
you can use "ScrollViewer" and "Stackpanel" as main content of "ScrollViewer".
then set the "Orientation". finally add list itmes as childrens of "Stackpanel"
please take a look at sample:
<ScrollViewer
Width="500"
MaxHeight="400"
VerticalScrollBarVisibility="Visible"
VerticalScrollMode="Enabled"
>
<StackPanel Orientation="Vertical" SizeChanged="items_modified_event">
<ListViewItem Content="item1" />
<ListViewItem Content="item2" />
<ListViewItem Content="item3" />
<ListViewItem Content="item4" />
.
.
.
.
</StackPanel>
</ScrollViewer>
The problem was with a fixed with. After removing it, the scrollbar is visible.
I have a ListView that uses a custom ItemTemplate (doesn't everyone?):
<ListView>
<!-- ... -->
<ListView.ItemTemplate>
<DataTemplate x:DataType="x:String">
<MyGreatControl Thing="{x:Bind}" />
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
MyGreatControl today has extensive keyboard handling code built-in, but due to some refactoring, I need to move the actual handlers to the ListView itself. However, I don't want to move all of the code in MyGreatControl to the ListView (for many reasons).
If I have an arbitrary ListViewItem (which, for example, I can get from an event handler), how can I access the MyGreatControl instance in its DataTemplate?
MyGreatControl^ GetMyGreatControlFromListViewItem(ListViewItem^ listViewItem) {
// ???
}
Disclaimer: I work for Microsoft.
You want to use ContentTemplateRoot!
MyGreatControl^ GetMyGreatControlFromListViewItem(ListViewItem^ listViewItem) {
return safe_cast<MyGreatControl^>(listViewItem->ContentTemplateRoot);
}
This also works for any arbitrary element—if you have a StackPanel, for example, ContentTemplateRoot will return the StackPanel instance you want:
<ListView.ItemTemplate>
<DataTemplate x:DataType="x:String">
<StackPanel><!-- This is what you get! -->
<TextBlock Text="{x:Bind}" />
<Button Content="Foo" IsTabStop="False" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
You can then use normal visual tree navigation to find Children, etc.
I'm starting my next electronics project which is to create my own version of Google's Nest Thermostat. I like the whole circular dial for temperature selection and I've been having a think about how to create this myself. GUI programming is not my area of expertise (CLI all the way!).
So far I'm think along one of two lines, both involving custom widgets:
Create a widget that inherits from the pushbutton class. This subclass will contain lots of buttons, one for each step in the temperature scale, arranged in a 3/4 circle.
Create a widget that inherits from the slider class, defining an object that is curved around 3/4 of a circle. Each step is a temperature.
Now... I have no idea if these are practical solutions to this problem or if there is a much easier way of doing this. I've had a look at the style sheets and I don't THINK that is going to do it. I've had a root around Google for anything similar and not found anything yet; that said, AnalogWidgets from 3electrons at least creates dials, but these are for output rather than input.
I tried this out yesterday and it works rather nicely if you want to simulate the nest thermostat in an app this includes the js and SVG image:
https://www.svidget.io/examples/nestthermostat
HTML snippet:
<object id="nestThermostatWidget" role="svidget" data="nestThermostatWidget.svg" type="image/svg+xml" width="400" height="400">
<param name="targetTemp" value="77" />
<param name="ambientTemp" value="80" />
<param name="unit" value="F" />
<param name="state" value="cooling" />
<param name="showLeaf" value="1" />
<param name="awayMode" value="0" />
</object>
I'm fairly new to SharePoint 2010, I've had some experience with 2007 but only debugging and fixing some small bug.
Assuming that i create a new solution for SP 2010 in VS2010 and i add a feature to create some list definitions and also some list instances of those list definition templates. These are all declared through Schema.xml =>
I deploy successfully and add a few items to my new lists.
Now i want to add a few extra columns (fields) to my lists, how will i deploy them?
I don't want to create them in code, i would like to have a up to date solution that with every new developer a simple deployment would create an up and running Dev environment.
What is the correct way to do the deployment in this case?
If you have the schema.xml file defined for the list, then you really want to add your new columns using the collection within the list definition. You also want to be sure your list is defined by a content type, allowing for reuse. So within your schema.xml file, it would look something like this:
<List xmlns:ows="Microsoft SharePoint" Title="Test List" FolderCreation="FALSE" Direction="$Resources:Direction;" Url="Lists/Test-List" BaseType="0" xmlns="http://schemas.microsoft.com/sharepoint/">
<MetaData>
<ContentTypes>
<ContentType ID="0x010068a2e063a1a74913a37ecdb61ab2c721" Name="Test" Group="Custom Content Types" Description="Test Description" Inherits="TRUE" Version="0">
<FieldRefs>
<FieldRef ID="{c2f80e7d-666e-4273-8b58-d5c8a13a9d6a}" Name="Col1" ShowInNewForm="TRUE" Required="TRUE" ShowInEditForm="TRUE"/>
<FieldRef ID="{a84d620a-d42d-455c-8ef8-7e9f1d443250}" Name="Col2" Required="TRUE" ShowInNewForm="TRUE" ShowInEditForm="TRUE"/>
<!-- Your new field refs here here -->
</FieldRefs>
</ContentType>
</ContentTypes>
<Fields>
<Field ID="{c2f80e7d-666e-4273-8b58-d5c8a13a9d6a}" Type="Text" AllowDeletion="FALSE" Description="Key" AllowDuplicateValues="FALSE" EnforceUniqueValues="TRUE" Indexed="TRUE" Name="Col1" DisplayName="Col1" Group="Custom Columns" />
<Field ID="{a84d620a-d42d-455c-8ef8-7e9f1d443250}" Type="Text" AllowDeletion="FALSE" Name="Col2" DisplayName="Col2" Group="Custom Columns" />
<!-- Your new fields here -->
</Fields>
...
</MetaData>
</List>
Don't forget to change your View as well!
I have two list that consist out of the same object.
I want to check if the first list containts an object of the second list
<ui:repeat var="item" value="#{userTypeController.permissionItems}">
<c:if test="#{userTypeController.permissionItemsUserType.contains(item)}">
<h:selectBooleanCheckbox value="#{true}"/>
<h:outputText value="#{item.getAction()}" />
</c:if>
<c:if test="#{!userTypeController.permissionItemsUserType.contains(item)}">
<h:selectBooleanCheckbox value="#{false}"/>
<h:outputText value="#{item.getAction()}" />
</c:if>
</ui:repeat>
but this doesn't seem to work and all I'm getting is false.
I've changed the equals and hashcode methodes but didn't help.
JSTL tags like <c:if> runs during view build time and the result is JSF components only. JSF components runs during view render time and the result is HTML only. They do not run in sync. JSTL tags runs from top to bottom first and then JSF components runs from top to bottom.
In your case, when JSTL tags runs, there's no means of #{item} anywhere, because it's been definied by a JSF component, so it'll for JSTL always be evaluated as if it is null. You need to use JSF components instead. In your particular case a <h:panelGroup rendered> should do it:
<ui:repeat var="item" value="#{userTypeController.permissionItems}">
<h:panelGroup rendered="#{userTypeController.permissionItemsUserType.contains(item)}">
<h:selectBooleanCheckbox value="#{true}"/>
<h:outputText value="#{item.getAction()}" />
</h:panelGroup>
<h:panelGroup rendered="#{!userTypeController.permissionItemsUserType.contains(item)}">
<h:selectBooleanCheckbox value="#{false}"/>
<h:outputText value="#{item.getAction()}" />
</h:panelGroup>
</ui:repeat>
See also:
JSTL in JSF2 Facelets... makes sense?