How to handle Namespace collisions when using TreeView in UWP apps - treeview

An exception is thrown when setting "ItemContainerStyle" to "StaticResource TreeViewItemStyle" which is defined in generic.xaml. The message indicates the style is using "Windows.UI.Xaml.Controls.TreeViewItem" rather than "Microsoft.UI.Xaml.Controls.TreeViewItem".
I removed ItemContainerStyle assignment to confirm that it is the line causing the exception.
<ControlTemplate TargetType="muxcontrols:TreeView">
<muxcontrols:TreeViewList x:Name="ListControl"
ItemTemplate="{StaticResource TreeViewItemDataTemplate}"
ItemContainerStyle="{StaticResource TreeViewItemStyle}">
The problem seems obvious, but a proper solution evades me. To leverage the style, do I start prepending "muxcontrols:" in the generic.xaml file? This seems like a bad idea. Do I need to recreate the style and behaviors separately?

I tried (min build 17763 and target build 17134) to eliminate version problems, but it seems I need 17763 for both. Even though, I am not setting ItemsSource. I'm trying the technique used in the docs: "learn.microsoft.com/en-us/windows/uwp/design/…" for the Music Library TreeView sample. My real project's min version is 16299.
So, the issue was clear. The TreeView control is introduced from build 17134. If you're using the platform APIs, you need to make sure that your project's target version is 17134 or higher. Since you said you want to set ItemsSource. ItemsSource and its related APIs require Windows 10, version 1809 (SDK 17763) or later, so you need to make your project's target version is 17763.
Then, you could directly use the TreeView control like the following:
<TreeView></TreeView>
If you're using Windows UI Library APIs, you need to follow the Getting started with the Windows UI Library
document to download and install the Windows UI Library. Please note:
Important: To use WinUI 2.1, your project’s Min version must be 14393 or higher and the Target version must be 17763 or higher.
Then, if you want to use the TreeView control in WinUI library, in your XAML page, add a reference at the top of your page
xmlns:controls="using:Microsoft.UI.Xaml.Controls"
On the XAML page, you could directly input the following:
<controls:TreeView></controls:TreeView>

Related

Xamarin Forms - Access controls in Target application (iOS/Android)

I am using Xamarin.Forms, shared project template.
Here, I add controls to the content page such as a Label through say framework provided StackLayout.
Now in target apps - say for iOS/Andriod, I just need to set some text for this label. I have some platform specific code where I want to change the text value for the Label created in Shared Project.
How to do that?
I understand, Custom Renderers could be used. Is there any straight forward way that I am missing here?
You can, of course, use custom renderers... but imho it would be an overkill.
I'd use OnPlatform method - something like:
myLabel.Text = Device.OnPlatform<string>("text for iOS", "text for Android", "text for Windows Phone");
You can also do the same from XAML if you wish, like shown in this article (search "OnPlatform" there):
http://developer.xamarin.com/guides/cross-platform/xamarin-forms/xaml-for-xamarin-forms/essential_xaml_syntax/
If the text you need is dynamic and you need to set it at run time from platform-specific project, than you need to assign your Label to some variable in the shared project and then reference this variable from platform projects.

Accessing resources XML from another library project in Xamarin.Android

I am trying to create a Xamarin.Android Component to send to the Xamarin Component Store, and I need to bundle my Colors.xml with it, so it is accessible to everyone using my component. I am setting the build action for the Colors.xml tp "AndroidResource".
So I created an Android sample application, when I add a reference to my library project's dll, I am able to use the colors defined, my project compiles and it runs, but I get no intellisense on Xamarin Studio. So that would be a bad thing for anyone using my library, as they would not be able to even see that the colors are available to use. You can see in this picture the colors defined are not available in the suggestions box.
If I add the Colors.xml directly into my project, I get Intellisense support, like this:
Is there a way to achieve the same result above when adding just the dll reference? Did I do something wrong or Xamarin.Android/Xamarin Studio doesn't support this kind of scenario?
EDIT: To be clear, I know this is a problem with Intellisense not being able to pick up the values, but is there anything I can do to make it work?

IBM SBT extension property not working

the example code on
https://greenhouse.lotus.com/sbt/SBTPlayground.nsf/JavaScriptSnippets.xsp#snippet=Social_ActivityStreams_Controls_Simple_Stream_All_Extensions
I can see all extensions UI being displayed, but three of four configured extension do not work
1. save in extension does not work
2. commenting in extension does not work
3. delete in extension does not work
can see errors on all three of them on developer tools
I believe this is previously answered by Francis SBT javascript library
basically the playground uses dojo layers, the controls don't work with dojo layers.
Download the Toolkit
Extract the Tomcat Instance
Point the Instance to Greenhouse (Edit Managed-Beans.xml for sbt.samples.web)
Try the Control from
https://host:8443/
Navigate to the Control and Run it.
it should work from there.

Monodroid Layout Folder support

I'd like to use qualifiers on my layout folders as per the android documentation, but the designer in VS doesn't seem to support them. For example layout-w600dp doesn't get sent to the emulator; the default axml file from the layout folder is used.
Does anyone know if these settings are supported in Monodroid? If so, how do you make them take effect?
I think w600dp requires a certain api level to work - maybe 3.2 - see http://android-developers.blogspot.co.uk/2011/07/new-tools-for-managing-screen-sizes.html

Monodroid Custom UI controls

I want to know where I can get access to the NinePatch images specifically for Monodroid. I want to change the default coloring from blue to orange (if I was doing this in Java it would already be orange).
All I need is to change an edittext so that it's default colors are different. I have seen
http://www.androidworks.com/changing-the-android-edittext-ui-widget
which is really helpful but only as far as vanilla Android is concerned. I tried following the instructions, but I found the standard orange java images, not the Mono ones, which are blue.
Minimum framework is 2.2. I know that I am getting the java images because when I go to C:\Android\android-sdk\platforms there is no android-2.2 folder.
I'm not really sure what you are referring to. Mono for Android does not ship any NinePatch images. Mono for Android simply provides a thin binding over the Java API, it does not do anything custom.
Maybe it is triggered by changing your Android target framework?
I found my answer - and thank goodnesss it did not involve changing the 9Patches!
You can make an xml in the drawable folder which describes your button, textbox, etc. and make a selector with a solid tag, pressed event, etc. (http://developer.android.com/guide/topics/resources/drawable-resource.html)
Then you can set up the colors as a constant set in the Values folder and boom! Solution!

Resources