I am absolutely new to WPF and trying to create some sample UIs in KAXAML. I need to have some emojis in the buttons therefore, I installed the emoji.wpf nuget package. By doing that, I am able to reference the emoji.wpf assembly in a Visual Studio project but if I try to refence the same assembly in a KAXAML file, it does not work.
As per this SO answer's suggestion, I have already copied the emoji.wpf.dll into the KAXAML folder (C:\Program Files (x86)\Kaxaml)
My Sample Code:
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:emoji="clr-namespace:Emoji.Wpf;assembly=Emoji.Wpf">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Button Grid.Row="0">
<StackPanel Orientation="Horizontal">
<emoji:TextBlock Text="đź”´"/>
<Label>MyLabel</Label>
</StackPanel>
</Button>
</Grid>
</Page>
Error in KAXAML
'Cannot create unknown type '{clr-namespace:Emoji.Wpf;assembly=emoji.Wpf}TextBlock'.'
Related
So, im new to UWP and im trying to make some sort of an app in UWP, where i want to print a list of Customers into the window so to speak. my XAML code looks like this:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="100"/>
</Grid.RowDefinitions>
<ListView ItemsSource="{x:Bind local:Customer}">
<ListView.ItemTemplate>
<DataTemplate x:DataType="data:Customer">
<StackPanel>
<TextBlock FontSize="16" Text="{x:Bind Name}"/>
<TextBlock FontSize="10" Text="{x:Bind Address}"/>
<TextBlock FontSize="10" Text="{x:Bind PhoneNumber}"/>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<TextBlock Grid.Row="1" Name="ResultTextBlock" FontSize="24" Foreground="Red" FontWeight="Bold" Margin="0,20,0,0"/>
</Grid>
What gives me an error is this:
<DataTemplate x:DataType="data:Customer">
I've been trying to look up an answer that could help, using my Solution name
using UwpNavigationTest1;
In all my files, doesnt make it go away. I cant really find the .VS file to remove, like a hidden file. Is there any other fix to this?
Kind Regards
Derive from official document
When using {x:Bind} with data templates, you must indicate the type being bound to by setting an x:DataType value, as shown in the Examples section.
The name “Customer does not exist in the namespace ”using:…" UWP
If you just place Customer class under the project's root folder, please replace x:DataType="data:Customer" with x:DataType="local:Customer". And if the Customer class in other namespace but not current project namespace, please using the namespace in xaml like the following.
<Page
x:Class="ListViewTest.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:data="using:ListViewTest.Model"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
mc:Ignorable="d">
......
<DataTemplate x:Key="DemoItemTemplate" x:DataType="data:Item">
For more info please refer UWP binding depth document.
I am trying to add the capability to view a PDF file from within my WPF application.
I have been following the tutorial at: http://www.codeproject.com/Articles/579878/MoonPdfPanel-A-WPF-based-PDF-Viewer-Control#include, and am at the section titled "Including MoonPdfPanel in your Application".
I have the following XAML:
<Window x:Class="DocumentViewer.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:DocumentViewer"
xmlns:mpp="DocumentViewer:MoonPdfLib;assembly=MoonPdfLib"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<DockPanel>
<mpp:MoonPdfPanel Background="LightGray" ViewType="SinglePage" PageDisplay="ContinuousPages" PageMargin="0,2,4,2" AllowDrop="True"/>
<Grid DockPanel.Dock="Top">
<Menu x:Name="menu" IsMainMenu="True" HorizontalAlignment="Left" Height="20" VerticalAlignment="Top" Width="518">
<MenuItem Header="_File">
<MenuItem x:Name="loadDocument" Header="Load Document" Click="openFileMenuItem_click"></MenuItem>
<Separator />
<MenuItem x:Name="exit" Header="Exit" Click="exitApplication_click"></MenuItem>
</MenuItem>
</Menu>
</Grid>
<Grid x:Name="browserHost" DockPanel.Dock="Top" Margin="0,0,0,0">
</Grid>
<!--mpp:MoonPdfPanel x:Name="PdfPanel" Background="LightGray" ViewType="SinglePage" PageMargin="0,2,4,2" AllowDrop="True" /-->
<!--mpp:MoonPdfPanel Background="LightGray" ViewType="SinglePage" PageDisplay="ContinuousPages" PageMargin="0,2,4,2" AllowDrop="True"/-->
</DockPanel>
</Window>
However, for some reason, I am getting a compile error on the line:
<mpp:MoonPdfPanel Background="LightGray" ViewType="SinglePage" PageDisplay="ContinuousPages" PageMargin="0,2,4,2" AllowDrop="True"/>
which says:
The name "MoonPdfPanel" does not exist in the namespace "DocumentViewer:MoonPdfLib
I downloaded the MoonPdfViewer from https://sourceforge.net/projects/moonpdf/?source=typ_redirect, and have ensured that it is in the root of my workspace... as far as I can tell, I have followed everything the tutorial says to do, and yet I am getting this compile error...
If I try to run the application, when it tells me that there were build errors, and asks if I would like to continue and run the last successful build, if I say 'No', 3 errors are shown in the console:
The name "MoonPdfPanel" does not exist in the namespace "DocumentViewer:MoonPdfLib;assembly=MoonPdfLib".
The property 'PageDisplay' was not found in the type 'MoonPdfPanel'.
The property 'PageDisplay' does not exist in XML namespace 'clr-namespace:MoonPdfLib;assembly=MoonPdfLib'. Line 11 Position 72.
What am I doing wrong here? How can I add this MoonPdfPanel to my application?
Just by looking at your code and the link you provided, your namespace is wrong.
You have:
xmlns:mpp="DocumentViewer:MoonPdfLib;assembly=MoonPdfLib"
It should be:
xmlns:mpp="clr-namespace:MoonPdfLib;assembly=MoonPdfLib"
Your local namespace may be DocumentViewer, but namespaces for 3rd party libraries use the project references. So, you don't include your namespace unless it's an actual component in your namespace, such as your own custom control. Even then, the namespace is delimited with a period, ., not a colon.
The panel is added as such:
<mpp:MoonPdfPanel Name="pdfPanel" DockPanel.Dock="Bottom" Background="LightGray"
ViewType="SinglePage" PageRowDisplay="ContinuousPageRows" PageMargin="0,2,4,2" AllowDrop="True"/>
I was able to load a PDF without any problems using:
OpenFileDialog ofd = new OpenFileDialog();
ofd.Title = "Select a PDF File";
ofd.Filter = "PDF File (*.pdf)|*.pdf";
if ((bool)ofd.ShowDialog())
{
pdfPanel.OpenFile(ofd.FileName);
}
The result looked like this:
I am using an external library which generates an class for UI in my game from XAML, everything generates fine and it's working as intended except for one part. It says the Root element does not exist in the namespace and thus I cannot use the designer, the creator of the library himself doesn't even know why it is doing this, it works fine for him.
<!--ek:UIRoot was not found/ does not exist in the namespace-->
<ek:UIRoot
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:ek="clr-namespace:EmptyKeys.UserInterface.Designer;assembly=EmptyKeys.UserInterface.Designer"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<TextBlock Text="Hello World" Grid.Row="0" />
<TextBlock Text="This is EmptyKeys In monogame" Grid.Row="1" />
</Grid>
</ek:UIRoot>
And yet it does
The project is .net4.5 and anycpu the same as what the library is built on and i've rebuild the solution many times. (those were the solutions to similar issues)
Am I missing something?
I needed to unblock the dll because it came from another computer
http://blogs.msdn.com/b/delay/p/unblockingdownloadedfile.aspx
the example is a zip but it applies the same for dlls
I've got a strange behavior with the Microsoft ribbon library (the library which is included in .Net Framework 4.5). If I hide the complete ribbon, the areas below the ribbon tab headers look really ugly. I've build a test application and was able to reproduce this behavior (screen below)
The code of this application is very simple:
<Window x:Class="RibbonLibraryTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid Background="Yellow">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Ribbon Background="White">
<RibbonTab Header="Test1"></RibbonTab>
<RibbonTab Header="Test2"></RibbonTab>
<RibbonTab Header="Test3"></RibbonTab>
<RibbonTab Header="Test4"></RibbonTab>
</Ribbon>
</Grid>
</Window>
To hide the ribbon, I double click on one of the ribbon tabs like in MS Word.
Seems to be a bug in the ribbon library. Is there a way to avoid this?
I'm trying to see a form developed by someone else (ex-employee) in Visual Studio 2008 but keep running into the following error when I try and look at MainForm.xaml (it fails to load in the designer view):
Error Could not create an instance of type 'NumericTextBox'. D:\MySolution\GUI\MainForm.xaml
My solution is organised something like this (shortened for brevity - it's the last line of this where the error occurs):
\solution
\Gui
\App.xaml
\MainForm.xaml
\Utils
\NumericTextBox.cs
My MainForm.xaml looks something like this:
<Window x:Class="MyCompany.MyDepartment.MyProject.MainForm"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:MyCompany.MyDepartment.MyProject"
xmlns:myproject="clr-namespace:MyCompany.MyDepartment.MyProject;assembly=MyProject"
xmlns:dsp="clr-namespace:MyCompany.MyDepartment.MyProject.DSP;assembly=MyProject"
xmlns:filters="clr-namespace:MyCompany.MyDepartment.DSP.Filters;assembly=DSP"
xmlns:mydepartment="clr-namespace:MyCompany.MyDepartment.Utils;assembly=Utils"
xmlns:scope="clr-namespace:MyCompany.MyDepartment;assembly=ScopeControl"
Title="MyProject" Height="900" Width="1024"
Loaded="Window_Loaded"
Closing="Window_Closing" ResizeMode="CanResize" Icon="/MyProjectGUI;component/MyProjectGUI.ico">
<Window.Resources>
...
</Window.Resources>
<DockPanel>
<StackPanel DockPanel.Dock="Left" CanVerticallyScroll="True" CanHorizontallyScroll="False">
<GroupBox Name="SensorControlGroup" Header="Sensor Control">
...
</GroupBox>
<GroupBox Header="Sensor State">
<StackPanel Name="SensorStackPanel">
<Expander Name="EnvironmentExpander" Header="Environment">
...
</Expander>
<Expander Name="SynthExpander" Header="Synthesiser" IsExpanded="True">
<Border Margin="2" Background="White" Padding="3">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"/>
<ColumnDefinition Width="60"/>
<ColumnDefinition Width="60"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Label Grid.Column="0" Grid.Row="0">Frequency (MHz):</Label>
<mydepartment:NumericTextBox Grid.Column="1"
x:Name="SynthFrequency" DecimalPlaces="3"
Maximum="0" Minimum="0" />
What might cause that error? Everything compiles okay but the application crashes when I run it. I was hoping the two problems might be a related issue.
The two issues you mentioned are almost certainly related. In both cases, the XAML file will be processed in order to create a control. One for design purposes and the other for runtime. If there is an exception being generated at runtime while parsing the file then it follows that the designer will also be having problems with the file.
I think you need to focus on the original bug and then come back to this one. One should almost certainly fix the other.
Okay, so it turned out that although Visual Studio was set up to use v3.5 of the .net framework you need to seperately install v3.5 of the framework - it seems I only had v2 installed. Let this be a lesson for anyone else struggling with the same problems!