Snapping to the edge - c#

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

Related

Windows.UI.Xaml.Markup.XamlParseException on NavigationView

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

Control Does Not Exist in Namespace

I'm attempting to use the MediaUriElement in the custom (WPFMediaKit).
I've added it into the namespace like so;
xmlns:controls="clr-namespace:WPFMediaKit.DirectShow.Controls;assembly=WPFMediaKit"
and then I have tried to access it;
<Grid>
<controls:MediaUriElement x:Name="mediaUriElement" />
</Grid>
however I just get an error: The name MediaUriElement does not exist in this namespace. VS does give me a suggestion to use it when I am typing though;
How can I correctly add this into my project?
I've tried and it is worked. What I've done:
Switched project from Framework 4.5 to Framework 4.0
Added references such as DirectShowLib-2005.dll and WPFMediaKit.dll to the project
Declared xaml namespace xmlns:controls="clr-namespace:WPFMediaKit.DirectShow.Controls;assembly=WPFMediaKit" like that:
<Window x:Class="ExcelExportWpfApplication.MainWindow"
... The code omitted for the brevity...
xmlns:controls="clr-namespace:WPFMediaKit.DirectShow.Controls;assembly=WPFMediaKit"
xmlns:vm="clr-namespace:ExcelExportWpfApplication.ViewModel"
mc:Ignorable="d"
Title="MainWindow" Height="550" Width="525"
WindowStartupLocation="CenterScreen">
And just written in xaml:
<controls:MediaUriElement Grid.Row="2"/>
No errors

Unable to load DLL in the WPF-project

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"

Can't access Windows 8 Store user control from code

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.

WPF / Xaml: tag not available. I just don't get it. Who can explain the compiler message?

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

Categories

Resources