I'm trying to create an "overlap" effect (for lack of a better term). There will be a splitter that when moved, exposes a different view of two similar images (e.g. between colored and grayscale).
I plan on using CustomGridSplitter from WinRTXAMLToolkit (due to WinRT's lack of a splitter). I'm thinking of starting with a grid similar to:
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="10" />
<RowDefinition />
</Grid.RowDefinitions>
<controls:CustomGridSplitter Grid.Row="1" Opacity="0.25"/>
</Grid>
... but I'm not sure how to proceed. If I specify two image controls on the first and third row (or column), how do prevent the image controls from moving (or so)? Also, is it possible to do this diagonally?
You could use two Rectangles that use an ImageBrush or two Image controls that use a Clip property to clip their contents. Unfortunately you can't have diagonal clips in WinRT, only rectangular ones. Maybe you could check if combining multiple RotateTransforms with a Clip would work, you never know. Other than above I would use a Slider instead of a GridSplitter for your scenario.
Related
Trying to build a bar chart where each bar is essentially 2 bars layered on top of each other, and the top-most bar will be thinner than the bottom bar.
I see the existing feature where if you provide a "stackId", it stacks it, but it is stacked above it, which isn't what I want.
I've been trying to customize a bar shape that supports this, but failing to do so.
What makes this more tricky is, we're using log scaling for the Y axis.
Any input on this would greatly be appreciated!
EDIT: Attaching a mock of what I'm trying to do:
layered bar chart
Great question. That certainly is possible. While rendering multiple Bar elements, they will be put on a single axis next to each other.
The trick is to use multiple x-axes. To show how this works, I added a new story to the Recharts storybook.
You can find the code for it in this PR and soon in the repo itself.
For the sake of a complete answer, I am duplicating the code here.
<ResponsiveContainer width="100%" height={400}>
<BarChart data={data}>
<Bar dataKey="uv" fill="green" xAxisId="one" barSize={50} />
<XAxis xAxisId="one" />
{/* The smaller bar must be rendered in front of the larger one to be visible. */}
<Bar dataKey="pv" fill="red" xAxisId="two" barSize={30} />
<XAxis xAxisId="two" hide />
</BarChart>
</ResponsiveContainer>
How to handle the events when someone clicks(mouse click) on the violet color space around the elements ?
Putting a general onclick on the container is overriding the individual item behaviors (they all have their internal onclick handlers). Any other way to solve this ?
Edit:
<Grid onClick={ClickHandler} container direction="row">
<Grid item>
// Filter Screen that has buttons, checkboxes
</Grid>
<Grid item>
............
</Grid>
</Grid>
The problem here is the container ClickHandler just overrides all the clickhandlers that the filter screen has. So that tactic was not successful.
The stopPropagation() method of the Event interface prevents further propagation of the current event in the capturing and bubbling phases. It does not, however, prevent any default behaviors from occurring; for instance, clicks on checkboxes are still processed.
<Grid onClick={ClickHandler} container direction="row">
<Grid item onClick={(e) => e.stopPropagation()}>
// Filter Screen that has buttons, checkboxes
</Grid>
<Grid item>
............
</Grid>
</Grid>
I have an idea that I think will work, but I'm not sure is the best approach or follows best practices. I would make use of the data- attributes on your components. Add an attribute like data-element="container" to your parent container. If event.target.dataset.element === "container" in your click handler, then you've clicked the background around the elements, otherwise you've clicked one of the elements. If necessary, you can also add data-element="componentN" to each of your components inside the container and move your logic for the onClick effects for your individual components inside there.
I have the following code (textinput).
<s:TextInput id="label"
text="just testing"
width="100%"
height="200"
contentBackgroundColor="#aaaaaa"
styleName="normalText">
</s:TextInput>
I am having a hard time finding how to align the text ("just testing") to the top.
I checked the Adobe documentation but it seems like there is no vertical alignment property available for this property.
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/controls/TextInput.html
I realize that there is a textarea component available but due to performance reasons, I need to use textinput.
topPadding seems to work for mx
<mx:TextInput
id="txt"
paddingTop="5"
text="I am Vertically aligned text"
textAlign="center"
width="250"
height="250">
</mx:TextInput>
Any tips would be greatly appreciated.
Thanks!
Quick version
If the font size never varies, it may suffice to just work with paddingBottom. Because by default the vertical alignment is set to middle, decreasing paddingTop alone will not suffice to move the text up sufficiently; it's set to 1px by default anyway. You'll have to increase paddingBottom too. I cannot give you exact numbers: it depends on the size of the font, so you'll have to play around with the values a bit.
<s:TextInput paddingBottom="6"/>
Reusable version
If you want your solution to be reusable with any kind of font, you'll have to create a custom skin for TextInput. Fortunately, that's not too hard:
Find the spark.skins.spark.TextInputSkin
Copy it and give it a new name, say my.skins.TopTextInputSkin
Find the RichEditableText tag with id textDisplay (it's at the bottom)
Set its verticalAlign property to top
Apply the new skin: <s:TextInput skinClass="my.skins.TopTextInputSkin"/>
I want to display list of items in my Metro applications. And I want to just display them. I don't want any kind selection, mouse-over, keyboard control, or animation effects.
The items will be displayed with ItemTemplate, the list will be data-bound and I want scrolling (both vertical and horizontal).
What would be the simplest way to do this? The ListView has lots of defaults, that make "simply displaying" items a heroic task.
The ListView can get rid of almost everything you want by setting SelectionMode="None" and IsHitTestVisible="False". This will give you no selection or highlight of any elements with mouse or keyboard. You will still get scrolling and supporting interactions for scrolling. You will still get animations, however.
Otherwise, you will probably have to look at using an ItemsControl and ScrollViewer to get the effect you want.
Use the ItemsControl in the first instance. You add your data template as you desire and use the ItemsPanel control to apply your layout. For example, the StackPanel below allows the orientation to switch to horizontal.
<ItemsControl ItemsSource="{Binding Users}" >
<ItemsControl.ItemTemplate>
<DataTemplate>
<Image Source="{Binding ImageUri}" Width="40" Height="40" Margin="5" />
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
In my .mxml file, I am populating two side by side Labels with text data from a database.
Like this:
<s:Label x="10" y="37.5" width="100%" text="{data.city}"/>
<s:Label x="86" y="36.75" width="100%" text="{data.state}"/>
Sometimes, I will get a particularly long piece of text data and this will cause the 2 labels to overlap each other and become totally unreadable.
I think this is happening because I have the x and y set. Is there a way to make this more dynamic?
Thanks!
I would recommend exploring different Flex layout containers.
HGroup
<s:HGroup>
<s:Label text="{data.city}"/>
<s:Label text="{data.state}"/>
</s:HGroup>
This provides the kind of layout it sounds like you're looking for from your example. However, you may also want to look at a few other containers Flex offers.
Form
Flex forms align data in ways that are often useful for creating, well, forms. You may want to consider this for your UI, especially if you're allowing a user to give input that persists back to your DB.
<s:Form>
<s:FormItem label="City:">
<s:Label text="{data.city}"/>
</s:FormItem>
<s:FormItem label="State:">
<s:Label text="{data.state}"/>
</s:FormItem>
</s:Form>
You could do a couple of things:
If you have a function that gets called to set the values of each label, reposition the labels based on the contents in that function.
If the values for the labels are bound to data so that you don't necessarily get notified when the data is refreshed, then it's time to override the updateDisplayList() method of UIComponent, and have it reposition your labels there.
There is a lot of efficiency that can be gained (which will improve your performance) by understanding and using the life-cycle of a UIComponent. There's lots of good info on the subject out there if you just google "Flex component lifecycle"
Good luck!
if you have to display your labels in a limited width, then you can use maxWidth property of labels, this will display your text in label, and if text is long then it will show some text and remaining in ... format.
<s:Label text="{data.city}" maxWidth="150"/>
Try set X of second label with the width of the first label + space + x first label.
So: first label width + space + x of first label