"Unable to resolve type" when referencing a xaml file through namespaces - xaml

I'm trying to build the example project that is provided in the Avalonia website but I'm having difficulty with certain parts.
I want to use a xaml element in a xaml window in another file like so:
<Window xmlns="https://github.com/avaloniaui"
xmlns:local="using:Buguette.Views">
<Panel>
<local:MusicStoreView />
</Panel>
</Window>
But I'm getting an error saying "Unable to resolve type MusicStoreView from namespace using:Buguette.Views". (MusicStoreView is the name of the file I'm trying to include here).
However everything works fine when I just copy the contents of the MusicStoreView file to where <local:MusicStoreView /> is supposed to be.
I followed the steps in the website but I'm still getting this error.
Any help would be much appreciated.

You need to use clr-namespace:
<Window xmlns="https://github.com/avaloniaui"
xmlns:local="clr-namespace:Buguette.Views">
<Panel>
<local:MusicStoreView />
</Panel>
</Window>
Sometimes you also need to provide the assembly name, such as:
xmlns:viewModels="clr-namespace:MyApp.Core.ViewModels;assembly=Myapp.Core"

Related

How to use TableView in Xamarin.Forms?

I am relatively new to the world of Xamarin.Forms and have a question with regard to Xamarin TableView.
I want to create a layout similar to the one shown below.
Question is, can I use TableView for this or is there an another option for this? Can anyone show this with XAML code please?
Thanks in advance.
Edit: Tabs in the bottom are not required.
I don't mean to be rude, but this is very easy to retrieve from the documentation pages and a bit of trying yourself.
To get you started, try this:
<TableView Intent="Settings">
<TableView.Root>
<TableView.Section>
<ImageCell Text="Invoice Customization" Source="Invoice_image.png" />
<ImageCell Text="Invoice Defaults" Source="Invoice_image.png" />
</TableView.Section>
<TableView.Section Title="Security">
<SwitchCell Text="Use Touch ID" />
</TableView.Section>
... etc.
</TableView.Root>
</TableView>
The arrows at the end of the cells and the footer text underneath the Security section are not possible with Xamarin.Forms out of the box, this will probably require you to write a custom renderer.

Confused with pe:documentViewer rendering pdf file in web app

I have a web app that uses primefaces extensions.
If I use
<pe:documentViewer id="verPdf"
height="500"
name="/resources/pdf/#{utentesBean.nomeFile}" />
it does not render PDF in view.
if I use
<pe:documentViewer id="verPdf"
height="500"
name="/resources/pdf/441.pdf" />
it shows the PDF .
Can anyone give an idea ?
Thank you.
I am one of the developers of the document viewer component and I just tested it and it worked fine with both of the following:
<pe:documentViewer url="/sections/documentviewer/#{controller.bookFile}"/>
<pe:documentViewer library="books" name="#{controller.hoodFile}"/>
One thing I noticed above in your example is you were not using URL you were using "name" attribute and name is meant to be used with "library" as in my example above as a relative path to a resource folder called "books".
I think you want to change your code to...
<pe:documentViewer id="verPdf"
height="500"
library="pdf"
name="#{utentesBean.nomeFile}" />

XUL textbox is not editable or visible

When using an XUL <textbox> element in the latest Firefox releases, I am not able to focus the element and write something into it. It worked in older versions, like 33. Using html:textarea instead seems to work. However, I would be happy to keep the original XUL element in my app and want to understand what is going wrong here.
When using the multiline attribute on the <textbox> element, the element is not visible at all!
Any hint or explanation would be great.
Here is my small test.xul file content:
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
<window
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html = "http://www.w3.org/1999/xhtml"
width="800"
height="800">
<textbox flex="1" />
<html:textarea flex="1" />
</window>
Found the problem.
I had an override rule in my chrome.manifest file which looked like this:
override chrome://global/locale/textcontext.dtd
chrome://myapp/locale/xulrunner_global_textcontext.dtd
The file was changed for firefox 38 and an additional ENTITY was added which is not defined in my file. Adding the missing ENTITY solved all problems.
Thanks Makyen for testing and inspiration.
The changes for those who are interested:
https://hg.mozilla.org/releases/l10n/mozilla-beta/de/diff/6f25b6d2dcf5/toolkit/chrome/global/textcontext.dtd

Default XAML page and New XAML page in Xamarin Forms is not identical

I am new to Xamarin development. I created new Xamarin XAML App(Xamarin.Forms Portable). In Portable Project there where MainPage.Xaml by default. To create MVVM Model I created three new Folders- Views, ViewModels, and Models. Now I added new MainPage.Xaml in Views folder and was going to delete the default MainPage.Xaml page. But here I see some difference in both pages. The default MainPage.Xaml have xmlns:local="clr-namespace:Test" but the new MainPage.Xaml does not. Again the new MainPage.Xaml have <Label Text="{Binding MainText}" VerticalOptions="Center" HorizontalOptions="Center" /> but the default one does not. The screenshots are:
What does these MarkUp mean.Why there is a difference. Does something needs to be changed. Can I delete the default MainPage.Xaml or should i copy it in Views.Does I need to copy the Markup from the default Page to the new one. If so why?
Thanks in advance
Both pages are identical, and will display in the same way.
On the second, there's an additional Xml namespace declaration:
xmlns:local="clr-namespace:Test"
It's only a declaration. You could remove it, or add it to the other page without effect. It's purpose is to be able to reference custom views declared in the current assembly and in the namespace (c# namespace, this time) Test, like this:
<ContentPage
...
xmlns:local="clr-namespace:Test"
x:Class="Test.MainPage">
<local:MyAwesomeView />
</ContentPage>
Awesome that you have decided to start with Xamarin and Xamarin.Forms!
While I understand you might be having these questions, this is some very basic XAML knowledge. The short answer is: you don't need to worry about it.
The long answer:
The reason that there is a difference in these pages is simply because it's just a template and whoever at Xamarin created the template for the project can be a different person than who created the template for a new XAML page. So they solved it different ways. Or maybe he had a good/bad day, who knows.
The Label in the first page is simply there to show you how to get started and so you won't start with an empty screen.
The extra namespace xmlns:local="clr-namespace:Test" is actually redundant in this new page but is already there so you can use the classes in your project.
It is actually the equivalent of the using list at the top of your classes. So whenever you need something from a different namespace you have to declare it there. So if you create a folder 'Controls' you can add a attribute xmlns:controls="clr-namespace:Test.Controls".
Note how I changed local to controls, this is the prefix you will use to define your instance. Also I have added the right namespace Test.Controls. Now if you want te show something on screen, in your XAML from the controls namespace, go like this:
<ContentPage xmlns:controls="clr-namespace:Test.Controls" x:Class="Test.MainPage">
<!-- some stuff here -->
<controls:ReusableControlHere />
</ContentPage>
Where ReusableControl can be your own version of a Label, Button or virtually anything.

Windows 8 XAML Multilingual Translations

I've used the Multilingual Toolkit to translate my app and have been testing it using pseudo-language. It works fine for strings I have translated in code (C#) but I can't work out how to make it so that the tag in XAML is automatically translated.
I've been using http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh965329.aspx as a tutorial but I can't figure it out. I've also searched on Google but still no luck.
For example, I created a "Watermark" text box (which inherits from TextBox which shows some text in by default it the user has not entered any text and the item does not have focus. The XAML looks like this (I replaced generic positioning stuff with '...'):
<local:WatermarkTextbox x:Name="TitleTextBox" Watermark="MainPage_EnterATitle" ... Style="{StaticResource TextBoxStyle1}" />
As you can see it is setting a property called Watermark with a 'tag' of the resource name that is being translated using the Multilingual tool. I'm not sure how to get this to automatically translate.
Another example is using the bottom app bar buttons:
<Button x:Name="bottomAppBar_unpinFromStartButton" AutomationProperties.Name="MainPage_UnpinFromStart" Style="{StaticResource UnPinAppBarButtonStyle}" Click="bottomAppBar_unpinFromStartButton_Click"/>
And I can see in the link above that it says:
MediumButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name
But I'm not really sure where this is meant to go.
Even with a button, which seems like it would be the simplest to translate I can't get it to work. The XAML is:
<Button x:Name="RemovePhotoButton" x:Uid="MainPage_RemovePhoto" Content="" HorizontalAlignment="Center" Margin="222,0,974,78" Grid.Row="1" VerticalAlignment="Bottom" Width="170" Height="45"/>
But when ran in the app or viewed in the designed the button stays blank, with no text on it.
The Resources are set up like this:
And it is filling the translated documents fine:
I am able to translate it in C# using the code from the link above, just not using XAML.
Just wondering if anybody could help me out or point me in the right direction to solve this.
Thanks
First what i think is missing in the name of your resources is the property that you want to set. While never used it myself, i would understand it like this:
Your xaml needs to be changed to
<local:WatermarkTextbox x:Name="TitleTextBox" x:Uid="MainPage_EnterATitle" Watermark="" ... Style="{StaticResource TextBoxStyle1}" />
And your resource needs an entry with the key
MainPage_EnterATitle.Watermark
And about the part with the
MediumButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name
This is only used if the referenced property is an attached property. Like if your Watermark property would be attached not part of the control. But in your case its not important.