project hierarchy
Hello. I have main XAML UWP View (MainTabbar.xaml) and Tab content view (MethodTabView.xaml). MethodTabView.xaml located in another folder. I need to embed MethodTabView.xaml within MainTabbar.xaml. Everything embeds fine if both files are in the same folder, but if files located in different folders, it doesn't working. Please help
If I understand you correctly, you want to use the xaml control that you've created in another folder, right?
You will need to add references to the Page. I think you might change a little bit for your code.
I've made a simple demo and you could refer to it. I created a new Folder called MethodFolder, then I created a new UserControl called TestUserControl. After that, I added the reference to the page where I want to use the user control. Like:
xmlns:Name="using:ProjectName.FolderName"
So here is the code that I'm using:
<Page
x:Class="TestReference.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:TestReference"
xmlns:MethodFolder="using:TestReference.MethodFolder"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
<MethodFolder:TestUserControl />
</Grid>
And this is the screenshot of my project:
Related
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.
I have a SketchFlow Project, which is a prototype of an application that we are designing, and I am at the stage that I would like to export the project to another format for sharing.
The first thing that I tried was:
File | Export | Export as Images...
However, after this had finished running, I only had 6 screenshots. I have over 30 screens in the prototype. Does anyone have any idea why all screens are not exported?
I then tried:
File | Export | Export to Microsoft Word...
And this results in the following error:
Any thoughts on what is happening here? I have tried looking for a log file, but I couldn't find one.
The final option which I have tried is:
File | Export | Package SketchFlow Project...
Which seems to work perfectly. However, I would like to embed the images into a design document, and don't really want to have to go through taking screenshots manually, which will be the last resort.
Update 1
Ok, seems like it is certain screens that are causing the problem. When I do the "Export to Microsoft Word..." option, and choose only the first screen, the Word document exports correctly. However, when I add in another screen (one of the ones that wasn't included in the "Export as Images" method, I once again get the error that I showed the screenshot of.
Update 2
As requested in comments, the layout of the pages are as follows.
Header Component - which shows overall title of the application, and some common buttons.
Navigation Component - Menu Structure for all top level pages
All screens, with the exception of the Login/Register page, have the Header and Navigation Component added to them
Some screens are using Sample Data to populate elements on the page. Others are just simple controls, laid out on the page.
Update 3
Ok, I have just done a pretty comprehensive test, and when using "Export to Microsoft Word..." if I exclude all the screens that use Sample Data, the export completes successfully. As soon as I include any screen with sample data, it throws the exception. I can only assume that the "Export as images..." is failing silently when it hits the first screen that has Sample Data in it.
This is a bug. It's related to resource resolution. You may be able to work around by making the ItemTemplate property local instead of the default resource.
For example, with a repro built using the databinding showcase instructions - http://www.microsoft.com/en-us/showcase/details.aspx?uuid=db8a7eb6-3039-4008-a9f2-f5c910bcddf3
Replacing the ItemTemplate
<ListBox HorizontalAlignment="Left" Height="330" Margin="73,40,0,0" Style="{DynamicResource ListBox-Sketch}" VerticalAlignment="Top" Width="535" ItemsSource="{Binding Collection, Source={StaticResource snowboardData}}" DataContext="{Binding Source={StaticResource SampleDataSource}}" ItemTemplate="{DynamicResource ItemTemplate}"/>
With
<ListBox HorizontalAlignment="Left" Height="330" Margin="73,40,0,0" Style="{DynamicResource ListBox-Sketch}" VerticalAlignment="Top" Width="535" ItemsSource="{Binding Collection, Source={StaticResource snowboardData}}" DataContext="{Binding Source={StaticResource SampleDataSource}}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<Image Source="{Binding Images}" HorizontalAlignment="Left" Height="64" Width="511"/>
<TextBlock Text="{Binding Text}" Style="{DynamicResource BasicTextBlock-Sketch}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Allowed me to export to Word.
This has been reported to Microsoft and should be fixed in a future VS/Blend update.
After some back and forth offline with #shawty, we believe we have come up with the reason why the export is failing. It is not specifically tied to doing an export when Sample Data is being included, but more specifically when using Sample Data with a Sketch Control.
This is what I did to verify this...
Created new Sketch Flow Project
Added ComboBox control to the page
Added DataSource to the Data tab
Added Collection Property
Added Simple Property to Collection
Edited Data to include some sample data
Bound the ComboBox to the sample data
Ran the application to make sure it is working
Ran the Export to Microsoft Word...
Everything worked correctly
I then repeated the "exact" same process using the ComboBox - Sketch control, and the Export to Microsoft Word... failed to function, displaying the error message shown in question above.
The suggested workaround from #shawty is as follows:
"The sketch controls are functionally exactly the same as the OOTB ones under the hood, they just have a different dictionary of styles applied to them, my suggestion would be to take the OOTB controls, add your own set of styles to them to give them a similar look and feel. You'd only have to define the resource dictionary once at application level for each appropriate control (Button, Label, Datagrid and any others you use) , and the entire application will just maintain the same look and feel."
While this is a perfectly viable solution, it doesn't take anyway from the fact that I believe that this is a bug in the Sketch Flow application. I just don't know where to raise the bug, as there doesn't seem to be a section on Microsoft Connect to raise a bug about Blend, and/or Sketch Flow. If anyone knows where I can take this, I would love to hear about it.
I am working in windows store apps and I need help..
I am trying to adapt my app for the differents visual state (FullScreenLandscape, FullScreenPortrait, Snapped, etc) and I need to reuse the controls for each visual state..
I create a grid for each visual state for example
<Grid x:Name="PortraitView" Visibility="Collapsed">
</Grid>
<Grid x:Name="FillView" Visibility="Visible">
</Grid>
<Grid x:Name="SnapView" Visibility="Collapsed">
</Grid>
but my problem is that I can not repeat the x:name of the controls that I set in the Grid= PortraitView..
how can I resolve it?
thanks
From MSDN
The most common usage of this property is to specify a XAML element
name as an attribute in markup. This property essentially provides a
WPF framework-level convenience property to set the XAML x:Name
Directive.
Names must be unique within a namescope.
For more information, see XAML Namescopes.
I am new to XAML and MVVM. I am trying to follow this demo
How do I use MVVM in a windows phone 7 application
. The problem I am facing is that when in my MainPage.xaml I try to point towards another view and do something like
xmlns:view="clr-namespace:MyMVVM.View"
..
..
<Grid x:Name="LayoutRoot" Background="Transparent">
<view:CustomerView x:Name="Customers" DataContext="{Binding Path = CustomerView}">
</view:CustomerView>
</Grid>
then i see an error message as
Element is already the child of another element
This error is just an error from the designer but will not prevent it from running. If you want to fix the error in the designer, you could easily just replace phone:PhoneApplicationPage by UserControl and rebuild and the designer error should disapear.
In my opinion, the animation is too long and too "jumpy" - I'd like to remove it or make it more subtle. Possible?
I think you have to re-template the ChildWindow. Check this link so you can copy the default template and make your desired changes to the animation.
Here's the full recipe:
Extract the Child Window Template. I like to use Blend for this: create an empty project of the same type as your target project, put a child window directly to the main page. Select Edit Template->Edit a copy... Blend creates a style for the ChildWindow.
In your target project, add a new "Silverlight Resource Dictionary". name it "ChildWindowResources". Copy the entire style from the Blend project to the ChildWindowResources.xaml. Remove the "x:Key="ChildWindowStyle1" from the copied style.
In your target's project App.xaml, add the "ResourceDictionary" section thet looks like this:
-
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary
Source="/MyApp;component/ChildWindowResources.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
Now you can edit the template and comment out these pesky animation sections under VisualState x:Name="Open" and VisualState x:Name="Closed"