WPF Custom Control Resources - wpf-controls

I have a custom control which needs to configure a MultiBinding in code, which requires a IMultiValueConverter. Is it good practice to use FrameworkElement.FindResource and require the Converter be definied as a resource or should I instanciate the converter in code?
I could have this in the theme Resource such that it is always there, but this seems a bit prone to mistake.

I don't follow your question, but maybe I can help anyways.
It usually just boils down to whether the converter makes sense outside the scope of your control. If not, declare it in your control. If it does, why does it? Should you perhaps be exposing properties on your control rather than the converter itself?
As for how you create it, you might want to check out this post that helps to keep your XAML cleaner.

Related

How to create custom abstract objects with attributes in Typo3?

I am now familiar with "basic" Typo3 - Usage and templating. Right now, I am stuck though, because I am not familiar with custom extensions etc.
I am looking for a way to represent Objects, that I get via methods of my own php-class from an XML-DB-Interface, in Typo3.
To be more precise :
I have a really complex XML-Interface and a php-class which is complete already, to interact with that interface, making methods available, that are meant to interact with different object-types in the underlying DB.
I now want to create abstract objects with the corresponding attributes in Typo3 to be able to work with them in typo3 (display/create/modify).
Furthermore, it would be helpful to find a way to "link" the functions of my php class to typo3-functions, so I can (perhaps?!) build up some kind of simple report-generator that generates conditional reports of those objects.
Could anybody lead me into the right direction and link (a) HowTo(s) or perhaps even examples that I could modify?
Thanks in advance, Oliver
Check how DBAL extension is coded.
https://docs.typo3.org/typo3cms/extensions/dbal/
You might want to implement this XML system as your own abstraction system to store your objects and use TYPO3 backend forms to manipulate those.

system.runtime.serialization and mvvmcross

I am stuck with this issue and I cant seem to solve it. I have my logic in a PCL and a a .Droid and .iOS clients.
I need to use the [serializable] attribute in my logic so I need to add a reference to system.runtime.serialization. The problem is there is a different dll for android and iOS how can I manage this? I did not encounter this problem before because I used shared files between the projects so each project had its own reference to the correct system.runtime.serialization and I could use the [serializable] attribute with no problems.
Have I missed something?
Thanks
Amit
In general I'd recommend avoiding trying to use the SerializableAttribute in portable code. That type of serialization is basically not portable. However, if you really need to do it, that attribute is actually treated specially and is represented by a bit on the type as opposed to a normal attribute. So if you define your own attribute with the same name and namespace in a PCL, the compiler will emit the bit and everything may just work like you need it to.

What is the reason for IBOutlets being private in Xamarin.iOS

The generated designer.cs properties are private by default (at least without manual tweaking of generated code). This makes coding against something like a UITableViewCell feel much different than if I were doing this in Objective-C.
The popular way in the case of UIxxxViewCells, at least from what I can tell, is for the UIxxxViewDataSource to populate the IBOutlet properties, and that the cell should only be responsible for anything related to drawing/rendering the view.
With Xamarin.iOS, we are unable to access these properties from the data source, and instead are required to provide additional setter methods to populate the cell. In this way, the cell is responsible for setting it's own properties.
Is this just "The .NET way" of doing things?
It's so that we don't break encapsulation by default.
The outlets belong to the object they're on, it should be able to choose whether they're able to be modified from the outside. The fact that they're properties is an implementation detail of the Xamarin.iOS outlets system - you should think of them as private fields.
If you wish to expose them, you can create properties that do so - preferably read-only.
It was probably done that way because that's how the other GUI designers in MonoDevelop worked at the time (still do). Auto-generated bindings to the native controls used by the user-designed control for toolkits like Gtk# are also created as private.
I'm not sure if other UI designers for .NET work (I've never used Visual Studio to develop GUI apps using Windows.Forms or WPF).
Feel free to file a feature request on https://bugzilla.xamarin.com to make them public - I'll gladly implement it, I think it probably makes more sense for them to be public. I haven't changed it mostly because no one has expressed that they wanted it be any other way.

Adding new section in control panel of Liferay

I want to add a new section in control panel of liferay and within that section I want to have my custom-portlet. I did it using ext. However I want to do it with hook . Is it possible ?
I don't think it would be that easy with a hook, because of the following reasons:
You can't modify in a Hook - the class com.liferay.portal.util.PortletCategoryKeys which contains the keys for displaying the different sections. The different sections are hard-coded in this class in a String array ALL.
You can't modify the logic of PortalImpl#isControlPanelPortlet() which uses the PortletCategoryKeys#ALL to determine if the request in question is for a control panel portlet.
Then you also have another method which you can't modify with a Hook and is used extensively PortalImpl#getControlPanelCategory()
Doing it with a hook:
I have not tried this but I think if you need to do it with a hook you would have to change all those JSPs which make use of PortletCategoryKeys#ALL and the methods of PortalImpl as stated above, and provide your custom implementation for all these methods in the JSP.
I would really like to know how you implemented it with an EXT may be just the steps or the methods you have overridden. So that I can try to convert those in terms of a hook.
This is as far as my understanding goes. Hope this helps.
With the advent of Marketplace, ControlPanel has a new category named "Marketplace" and that section is introduced in a plugin. However, I never checked if 6.1 GA2 introduced a new section that this plugin just fills. Check the marketplace plugin if you can find a trace of this section implemented there.
On the other hand, nobody has yet named any section that definitely required a new section (though some have asked me how to solve the same problem). For this reason, you might want to re-think the requirement and choose one of the existing sections. If you don't, at least I'd be interested in the name and purpose of the new section - I might find a first one actually justifying this kind of implementation...

Per-view command state in RCP?

I am defining a command that will be used in the view toolbar and/or context menu for multiple views, some of which can have multiple instances. The command has a toggle state (org.eclipse.ui.commands.toggleState). The documentation seems to suggest using org.eclipse.ui.handlers.RegistryToggleState as the state implementation class, but this stores the state per-command, not per-view-per-command as I would need.
I do not need persistance between sessions. Is there a simple/preferred way to achieve this, or should I implement my own state?
I have done this. I could not find any standard API in Eclipse, so I ended up writing my own stuff for it. Which is relatively simple.
AFAIK there is no direct approach. You can solve this issue by following below steps
implement your own org.eclipse.ui.ISourceProvider and add an extension org.eclipse.ui.services
maintain state per view and populate state info in public Map getCurrentState();
please look at WorkbenchSourceProvider for reference.

Resources