I wanted a bit of advice.
I want to have a placeholder for an image (the image changes at the users will) and I want a placeholder for some other component.
Now, I have to interchange the z-index of these components so that some time the image is on the top and some other time the second component is on the top.
I am building the interface in Silverlight. This is a newbie question. Can anyone please suggest me, which component should I use as-in canvas, grid etc. that could facilitate the easy switching of the z-indices of the 2 components.
Thanks for your help.
Both Canvas and Grid honour the Canvas.ZIndex attached property, so either will do. However a more elegant approach might be to use the Visibility property to show / hide the placeholder elements.
i.e. when you want to hide your placeholder use the following:
placeholder.Visibility = Visibility.Collapsed
This is better than using Z index in my opinion
Related
The grid is a nice table that fits well for wide screens like desktop or tablet. However, when showing on smaller mobile device the grid will not fit with more than a few columns. How did you solve this problem in your application?
The table stack pattern sounds promising: https://responsivedesign.is/patterns/data-table-stack/
But how could I implement this with Vaadin Flow? Is there a possibility to exchange the grid with an item list depending on the screen size?
A common approach is to have separate columns for mobile and desktop.
On mobile, or other narrow screens, there might only be one column in a stacking manner. This is quite simple to do with template renders, and a template along the lines of
<div>Name: [[item.name]]</div><div>E-mail: [[item.email]]</div>"
It's even possible to define the template as a Polymer template web component, import it, and set a template renderer like this
<mobile-column item="[[item]]"></mobile-column>
To toggle columns, one can add a resize listener (preferably throttled), e.g. as defined here.
The MediaQuery add-on is also very useful for this. I recommend toggling the visibility on the server, to avoid sending unnecessary data and doing unnecessary rendering in the browser.
I would go with media queries. There is an example here to include them in styles : Media queries in Shadow dom
So, for example, in case width is less than some pre-defined value, set visibility of grid to hidden and list to visible and vice versa, when needed.
Edit: there is also an add-on which might help in using queries : Mediaquery
I need to develop a simple WPF application. In the UI window, There are Labels and Text Blocks towards the left and Buttons towards the right.
Figure 1
Based on a config setting (whether the user is left-handed or right-handed) I need to switch the controls, Buttons towards the left and Labels and Text Blocks towards the right.
Figure 2
Can you please recommend a good way to address this requirement?
Depends what the scope of the app is likely to be.
2 alternatives:
1)
I think it likely as an app grows that there will be more than just buttons.
I would probably build a usercontrol which encapsulates this behaviour for a label and control. The usercontrol uses a static to decide where the textblocks are positioned but would look something like the row edit control in this:
https://gallery.technet.microsoft.com/WPF-Entity-Framework-MVVM-78cdc204
Which is a usercontrol has a contentpresenter in it so you can put any control you like ( such as a button ) "in" it and set a dependency property for the label.
2)
Define 2 contentcontrol templates similar to the one used in this:
https://social.technet.microsoft.com/wiki/contents/articles/28597.aspx
Put them in separate resource dictionaries and give them the same key.
Merge into application.current.resources the appropriate resource dictionary and hence style.
Seeing as this is an app setting, this is presumably a start up thing. People don't just change their "handedness" dynamically. So you could probably use these as staticresource. If they're realistically going to change at run time then I think this would be a bit more involved because you'd need to force re render of a view.
2 Templates are probably the right and stylish solution here as #RajN said.
Also you can define a grid with 2 columns and switch the property 'Grid.Column' of each controls accordingly
Maybe not the best way, but I managed to achieve this using a grid as per your suggestions. Thank you all for your valuable feedback.
I switched the columns and changed the widths accordingly.
if (AppSettings.IsLeft)
{
parentGrid.ColumnDefinitions[0].Width = new GridLength(400, GridUnitType.Pixel);
parentGrid.ColumnDefinitions[1].Width = new GridLength(1, GridUnitType.Star);
Grid.SetColumn(buttonGrid,0);
Grid.SetRow(buttonGrid,0);
Grid.SetColumn(contentGrid,1);
Grid.SetRow(contentGrid,0);
}
Hi,
I am trying to achieve a similar screen to the one attached here using codename one. Its such that when a question is clicked, the answer drops down beneath it. The text would also have proper line breaks as it fills the screen width.
Is there any component I can use in achieving this using codename one?
I would suggest using the Tree component and setting the icons to null explicitly. This should work reasonably well for something like that and include the animation etc.
I'm using the Winforms PropertyGrid; the target of the SelectedObject includes a property of type Image. Everything is fine, except that with all items the same height, the image is too small to see properly. I'd like to have some control over the height of grid items such that the image can be displayed a bit larger. One other detail is that the SelectedObject of one PropertyGrid control may be assigned an object of any of a variety of different classes (which may or may not have image properties), so I'm hoping the height can be driven by data in the instance of the SelectedObject itself, rather than making it a static behavior of the control, although I'd settle for a custom attribute of the image property to make the item height at least class-specific if it can't be instance-specific.
How can I do this? Custom attribute? PropertyGrid event? Something else?
As Simon commented on your question, this is not possible to have a custom height for a GridItem.
You have 2 solutions to be able to show an image with a reasonable size:
You can code your own UITypeEditor. That way, the user would just click the down arrow and see a nicely sized image in the dropdown box.
Sorry for the plug but I think it directly answers your question: only 3rd party PropertyGrids may allow you to get variable size rows in the grid. Smart PropertyGrid.Net is one of them. You set a HeightMultiplier to the row so that it expands on let's say 4 rows. Then you code your own Look class that handles the drawing of the image the way you want in this space.
I'm trying to apply a specific style to a slider control and I'm having trouble figuring out what I need to do for the slider's background. What do I need to do to get something like this triangle to show in the background of my slider?
I initially thought I would define a GeometryDrawing and set something in the tickbar tag to it - but I can't find anything suitable.
This is what I'm looking for. Thanks for any ideas.
Slider background http://img16.imageshack.us/img16/690/slider.png
Check out my Intuipic project, which does something similar (only horizontally):
you need to investigate a bit more into styling and templatiting in wpf. I would expect the easiest way would be to define a Control Template but you 'might' be able to achieve this with just styling
Check out this page on msdn for starters. There is probably loads of other resources out there. Big sections on it in the book i'm reading at the moment - pro wpf in c# 2008
Sorry i'm not coming up with an example... you'd be better off doing a bit of background reading and then coming back with any specific issues.