I'm trying to make an Hierarchical Navigation View with XAML in a UWP project using a almost unnedited copy of the XAML Controls Gallery App code sample.
It doesn't show any error while compiling but when the app starts it crashes returning the following exception on the code behind at InitializeComponent():
Windows.UI.Xaml.Markup.XamlParseException: Cannot found the text for
this error code Cannot find a Resource with the Name/Key
TabViewButtonBackground [Line: 41 Position: 33]
XAML code:
<Page
x:Class="XizSoft.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:XizSoft"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
mc:Ignorable="d"
>
<muxc:NavigationView x:Name="nvSample8">
<muxc:NavigationView.MenuItems>
<muxc:NavigationViewItem Content="Home"
Icon="Home"
Tag="SamplePage1"/>
<muxc:NavigationViewItem Content="Account"
Icon="Contact"
Tag="SamplePage2">
<muxc:NavigationViewItem.MenuItems>
<muxc:NavigationViewItem
Content="Mail"
Icon="Mail"
Tag="SamplePage3"
/>
<muxc:NavigationViewItem
Content="Calendar"
Icon="Calendar"
Tag="SamplePage4"
/>
</muxc:NavigationViewItem.MenuItems>
</muxc:NavigationViewItem>
</muxc:NavigationView.MenuItems>
<Frame x:Name="ContentFrame"/>
</muxc:NavigationView>
Code-behind:
public MainPage()
{
InitializeComponent();
}
I've found the solution for this problem.
I just needed to add the following line on my App.xaml resources:
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
Source: https://vijirajkumar.blogspot.com/2020/08/uwp-navigationview-cannot-find-resource.html
Related
I am trying without success to compose a xaml page with an usercontrol. The purpose is to lighten the main page.
here is the UserControl beginning:
<UserControl x:Class="WpfApp1.richTextSummary"
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:local="clr-namespace:WpfApp1"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Layout.Toolkit"
xmlns:Controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit"
>
<dxb:BarManager x:Name="barManager1" ToolbarGlyphSize="Small">
and here is a part of the mainPage xaml reusing this userControl:
<TabControl Width="{Binding Width, ElementName=gridFields}">
<TabItem Header="Résumé">
<controls:richTextSummary></controls:richTextSummary>
</TabItem>
<TabItem Header="Fin"/>
</TabControl>
The problem is that in my userControl, I define a component which is given a name (rater) and I initialize this component in the mainpage code behind (in its constructor):
rater.Value=2;
It seems that when the constructor is called, the code is not injected and parsed...
Have you got a idea to solve this?
Maybe just a copy&paste error but I noticed that you are missing the namespace-declaration for the DevExpress-Bars assembly! Could that be the cause of your problem?
xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars"
I do have a UserControl (works) which I would like to use in a WPF project. When I run the application I get following error
Unable to load DLL 'VCECLB.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)"
This is a C++ dll and if I add it under references it goes to the project folder like this:
I also add it in the output folder \bin\x64\Release but without success. What I am doing wrong here? Any feedback would be highly appreciated!
UPDATE:
The XAML for loading the UserControl looks like this:
<Window x:Class="WpfApplication1LL_Neu.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:lowLightGrab="clr-namespace:LowLightGrab;assembly=LowLightGrab"
Title="MainWindow" Height="350" Width="525">
<Grid>
<WindowsFormsHost Height="290" HorizontalAlignment="Left" Margin="16,10,0,0" Name="windowsFormsHost1" VerticalAlignment="Top" Width="475">
<lowLightGrab:UserControl1/>
</WindowsFormsHost>
</Grid>
</Window>
Thanks
Once added as reference it will be copied to output folder.
For design time you have to add in your Window:
xmlns:VCECLB="clr-namespace:VCECLB;assembly=VCECLB"
I'm writing a Windows 8 Store application and within that I've designed my own user control.
Here is the code for my usercontrol (This is a dummy control but the problem exists with this):
<UserControl
x:Class="Windows8StoreTest.TestUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Windows8StoreTest"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Width="70"
Height="40">
<StackPanel>
<Button Content="Hello" Foreground="Pink" BorderBrush="Pink"/>
</StackPanel>
</UserControl>
I've dropped the user control onto my page and give it a name:
<Page
x:Class="Windows8StoreTest.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Windows8StoreTest"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<local:TestUserControl Name="testControl"/>
</Grid>
</Page>
However, when I go to the code behind I can't access the control by that name. It doesn't seem to exist! What is weird is that the control doesn't exists within InitializeComponent() method for the MainPage class which will be why it does exist.
What am I missing from my user control?
I'm using Windows 8 Store, XAML, c#.
Thanks in advance
Try to use this:
<local:TestUserControl x:Name="testControl"/>
Should work...
hello i don't know what is wrong but it should work.i have just made a sample example of it..i am putting it here hope you have done the same way.
<Page
x:Class="App12.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App12"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<local:MyUserControl1 x:Name="hellousercontrol" />
</Grid>
in my mainpage.cs.. i have just use it like this..
public MainPage()
{
this.InitializeComponent();
hellousercontrol.Height = 100;
}
one more this..have build your solution ?
I had the same issue in c++ environment. I observed, I didn't had default constructor in my class, as soon as I added the default constructor, I could use the defined UserControl in my project through XAML file. However without default constructor I was able to use it from within c++ code.
How can I snap a simple window to the screen(desktop) edge?
I've found this post using a library called Huddled, but I can't compile with it.
Is something wrong?
<Window x:Class="CMD_Bar.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:huddled="http://schemas.huddledmasses.org/wpf"
Title="CMD" Height="500" Width="500" Topmost="True" WindowStyle="None" AllowsTransparency="True" FontSize="12">
<huddled:Native.Behaviors>
<huddled:SnapToBehavior SnapDistance="20" />
</huddled:Native.Behaviors>
<Grid>
<Label Content="Something" />
</Grid>
EDIT:
Here are the error messages:
The tag 'Native.Behaviors' does not exist in XML namespace
'http://schemas.huddledmasses.org/wpf'. Line 9 Position 6
The type 'huddled:SnapToBehavior' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built. D:\CMD-Bar\CMD-Bar\MainWindow.xaml
I am new to WPF / Xaml. I tried to run a demo program to test WPF with NHibernate. I used the VmWrapperDemo but i cant get it compiled!
<Window x:Class="VmWrapperDemo.View.WindowMain"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="clr-namespace:VmWrapperDemo.ViewModel;assembly=VmWrapperDemo"
Title="VM Collection Demo" Height="325" Width="500" WindowStartupLocation="CenterScreen">
<Window.Resources>
<!-- Value Converters -->
<vm:ContactConverter x:Key="ContactConverter" />
<vm:AmountConverter x:Key="AmountConverter" />
<vm:DateConverter x:Key="DateConverter" />
</Window.Resources>
</Window>
It is the
xmlns:vm ...
definition which i dont understand and gives me headaches. What does it mean i why do i get the following compiler error:
"The tag ContactConverter is not available"
I am lost! Please help!
Try this
change assembly=VmWrapperDemo to assembly=VmWrapperDemo.ViewModel
Assembly name in the link you gave is VmWrapperDemo.ViewModel not VmWrapperDemo