I wrote a Windows Phone 8.1 (WINRT) App. I need to show Calendar in the page. So, I added WinRT XAML Toolkit - Calendar Control from nuget.
PM> Install-Package WinRTXamlToolkit.Controls.Calendar
<Page
x:Class="DrFit.Pages.ActivityTimeTablePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:DrFit.Pages"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:WinRT="using:WinRTXamlToolkit.Controls"
Background="Black">
<Grid x:Name="LayoutRoot">
<WinRT:Calendar Height="500">
</WinRT:Calendar>
</Grid>
</Page>
How to Customise this Calendar control, example FontWeight,Foreground,Background?
If the properties aren't exposed by the control or template-bound to template part properties - you'll probably need to change the template. You can find the default template here and templates for calendar parts are in the same folder:
WinRTXamlToolkit.Controls.Calendar/WinRTXamlToolkit.Controls.Calendar.Shared/Controls/Calendar
You probably have figured out the answer to this but I was facing a similar problem and figured out a solution so I thought I'd post it here for anyone else who faces a similar conundrum. If the calendar control is going out of the page, you can wrap it inside a Viewbox so that it fits the screen. This is how I managed to do it.
<Viewbox Stretch="Uniform">
<Grid Height="600" Width="600">
<toolkit:Calendar HorizontalAlignment="Center" VerticalAlignment="Center" Tapped="Calendar_Tapped"/>
</Grid>
</Viewbox>
Related
I'm using a passwordbox control in a UWP app. By default it shows an eye icon with the help of which user can see the password to know if he typed it correctly or not.
Here is my current code:
<Page
x:Class="UwpApp.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UwpApp"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<PasswordBox HorizontalAlignment="Left" VerticalAlignment="Top" />
</Grid>
</Page>
Although I'm targeting my application for windows 10 but I want to get rid of this password showing capability as per my applications requirement
Interestingly, this password showing capability is absent from the passwordbox control available for WPF applications?
You can add PasswordRevealMode="Hidden" in the PasswordBox
PasswordBox
Hi i just recently found out that you can use components from WPF and add into windows form just by creating them and later adding then into the form as element Host
So what i am trying to do is to create a video player using MediaElement and i also know that you can use Direct X or use Windows Media player for this put i want to custom make some controls in this so here is my question
when i try to add a the media element into my windows form it give me this error
here's my code for the mediaelement wpf
<UserControl x:Class="Videoplayer_2._0.MediaPlayer"
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:Videoplayer_2._0"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<MediaElement x:Name="mediaElement" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
</Grid>
</UserControl>
So is adding mediaElement just doesn't work or i did something wrong and also i added a WPF slider into the form also just saying because i have no idea if it will affect it or not
You just need to restart Visual Studio I think.
I wrote a Windows Phone 8.1 (WINRT) App. I need to show Calendar in the page with Highlighted days like holiays. So, I added WinRT XAML Toolkit - Calendar Control from nuget.
PM> Install-Package WinRTXamlToolkit.Controls.Calendar
<Page
x:Class="DrFit.Pages.ActivityTimeTablePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:DrFit.Pages"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:WinRT="using:WinRTXamlToolkit.Controls"
Background="Black">
<Grid x:Name="LayoutRoot">
<WinRT:Calendar Height="500" x:Name="ActivityCalender">
</WinRT:Calendar>
</Grid>
</Page>
I have two questions:
1: The calendar control goes out of margin on right side of phone. Where to change template so that it automatically adjusts according to page/frame width?
I copied its four xamls and used these as ResourceDictionaries.
2: Another question, I want to highlight some dates (for example, Holidays) by changing the color of their borders. Where shall I bring this color change in XAML? Highlighted dates should be in different color than a selected date. – Also, please tell me how to highlight these dates (for example, Holidays), which method to use ?
Highlighting a day removes the previously highlighted day.
ActivityCalender.SelectedDate = new DateTime(2015, 6, 21);
Try to place calendar control inside a Viewbox control and it will automatically fit control according to the Viewbox control provided width & height.
<Viewbox Width="300" Height="300">
<WinRT:Calendar x:Name="ActivityCalender" Style="{StaticResource CalendarStyle2}" FontSize="36" FontWeight="Normal" Padding="0" CalendarDayButtonStyle="{StaticResource CalendarButtonCustom}" HorizontalAlignment="Left" VerticalAlignment="Top"/>
</Viewbox>
once done you can download the style code from the link below.
Download Style code for WinRT XAML Tooklit Calendar Control - Windows Phone 8.1
and you will get the output link below image. You can also do customization in style.
I need to add a Windows form User Control (Barcode_Scanner.cs) to a WPF View (MainWindow.xaml)
Is there a simple way to do this?
Any help would be appreciated.
You can host Windows.Forms controls using the WPF WindowsFormsHost element.
Example:
<Window x:Class="WpfApplication10.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:winforms="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
xmlns:myControls="clr-namespace:MyContromNamespace;assembly=MyContromNamespace"
Title="MainWindow" Height="195" Width="191" Name="UI">
<Grid>
<WindowsFormsHost>
<winforms:Button Text="StackOverflow" />
</WindowsFormsHost>
<WindowsFormsHost>
<myControls:MyUserControl />
</WindowsFormsHost>
</Grid>
</Window>
Result:
you can do it with WindowsFormsHost
So the first thing that we need to do (after creating a new WPF project) is add a few references. You can do this by by right-clicking on the references folder in the solution explorer, and choosing "Add Reference":
Then you will get a dialog like this:
and so on wpf-tutorial-using-winforms-in-wpf
I can create UserControl and add TextBox very easily in Surface environment. Here is a sample code:
<UserControl x:Class="ScatterViewSizingSample.FixedSizeChild"
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:ScatterViewSizingSample"
mc:Ignorable="d" local:PopupWindow.InitialSizeRequest="300,250"
d:DesignHeight="300" d:DesignWidth="250">
<Grid Background="MediumSeaGreen">
<TextBox HorizontalAlignment="Left" Name="textBox1" VerticalAlignment="Top"/>
</Grid>
</UserControl>
I tried to add SurfaceUserControl and SurfaceTextBox, but I cannot find to add SurfaceUserControl from the menu. I changed UserControl to s:SurfaceUserControl and Texbox to s:SurfaceTextbox as follows:
<s:SurfaceUserControl x:Class="ScatterViewSizingSample.FixedSizeChild"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="http://schemas.microsoft.com/surface/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:ScatterViewSizingSample"
mc:Ignorable="d" local:PopupWindow.InitialSizeRequest="300,250"
d:DesignHeight="300" d:DesignWidth="250">
<Grid Background="MediumSeaGreen">
<s:SurfaceTextBox HorizontalAlignment="Left" Name="textBox1"/>
</Grid>
</s:SurfaceUserControl>
But the system shows error that 'the type s:SurfaceWindows does not found'. I added Microsoft.Surface.Presentation and Microsoft.Surface.Presentation.Generic assembly reference. But it still shows error.
How can I fix it? Why the system does not show SurfaceUserControl as UserControl?
An application using Surface controls needs to use SurfaceWindow as it's root visual in order to do all of the custom touch handling. I suspect that since you're trying to convert this you are probably still using a standard Window which is giving you this error.
If you're developing for 2.0, SurfaceUserControl no longer exists, as per MSDN:
The SurfaceUserControl class has been removed in Surface 2.0. The SurfaceUserControl class was needed in Surface 1.0 SP1 to add touch support to user controls. However, touch support has been added to the UserControl class in .NET Framework 4. To convert your code, remove "s:Surface" from the front of "s:SurfaceUserControl", or use the Surface Migration PowerToy.
Source