change the calendar control in WPF - c#

Is there a way to change the current calendar control in wpf or telerik? I am doing translation in my application. When I change language to Japanese, is there a way to include the Japanese calendar control instead of the English one.

Set the FrameworkElement.Language property of your control or apply the xml:lang attribute to the XAML of your control. The value you have to set is xml:lang="ja-JP".
from msdn CultureInfo
For example,
XAML:
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xml:lang="ja-JP"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Calendar />
</Grid>
</Window>
Output

Related

WPF | It Is Possible To Use Default WPF Style On A TextBlock In HandyControl Window ? [KIND OF SOLVED]

If i have this code, how can i indicate to the TextBlock in HandyControl Window to use the default WPF Style and not the HandyControl one ?
Thanks in advance ! :)
<hc:Window
x:Class="TextTrimming_Test.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:TextTrimming_Test"
xmlns:hc="https://handyorg.github.io/handycontrol"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800" Background="#181818">
<TextBlock Text="I want to be the default WPF TextBlock !"/>
</hc:Window>

How to split wpf xaml page into more maintainable small parts

I'm creating a wpf application and the main page consist of a sidebar a header and a content area where the rest of the app will be displayed, since i come for an angular background can i split the sidebar and the header and the content area into small maintainable components and how can it be achieved
In your Solution Explorer, right click on your project and add a new UserControl. Call it for example "FeatureView". In that UserControl, insert a textblock with a dummy text like:
<UserControl x:Class="WpfApp10.FeatureView"
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:WpfApp10"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<TextBlock Text="This is my FeatureView UserControl"/>
</Grid>
Then, in your MainWindow load it in the following way:
<Window x:Class="WpfApp10.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:WpfApp10"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<local:FeatureView/>
</Grid>
You should be able to see your dummy text. You can expand this with more UserControls.
You can split the areas into user controls:
https://learn.microsoft.com/en-us/visualstudio/extensibility/adding-user-control-to-the-start-page?view=vs-2017
A nice way of managing this is to use Prism Regions, see:
https://rohiton.wordpress.com/2016/06/08/understanding-prism-part-2-regions/

C# WPF UserControl based on Uniformgrid

I'm trying to make the user control on the basis of UniformGrid. When using office error appears: The property 'Content' is set more than once
AdaptiveLayout.xaml
<UserControl x:Class="App.Controls.AdaptiveLayout"
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:element="clr-namespace:App.Controls"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<UniformGrid SizeChanged="UniformGrid_SizeChanged">
<ContentPresenter></ContentPresenter>
</UniformGrid>
</UserControl>
MainWindow.xaml
...
<controls:AdaptiveLayout TransferringAfter="190">
<controls:TextBoxWrapControl LabelContent="FirstName"></controls:TextBoxWrapControl>
<controls:TextBoxWrapControl LabelContent="LastName"></controls:TextBoxWrapControl>
</controls:AdaptiveLayout>
...
You are using a UniformGrid in your UserControl, but that does not actually make it into one. That's why it's complaining in your MainWindow.xaml that you set more than one content for your AdaptiveLayout.
You could try extending UniformGrid instead of using it.

hide control while resizing window in wpf

I'm trying to hide a control during a window resize because it's not behaving right otherwise. However in WPF there doesn't seem to be any OnBeginResize-ish event.
Any suggestions how to achieve this in WPF?
Bind a property(Notifiable) to your window width so when the width changes Setter of this property will be invoked and within this setter you can have the logic to hide your control.
<Window x:Class="SiemensEnergy.Frw.Main.Client.UI.Views.MainWindowView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:viewmodel="clr-namespace:SiemensEnergy.Frw.Main.Client.UI.ViewModels"
Title="MainWindow" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
Width="{Binding WindowWidthProperty, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
</Window>
Window_SizeChanged?
<Window x:Class="TestControls.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:m="clr-namespace:WFControls;assembly=WFControls"
xmlns:ff="clr-namespace:WFControls.Fernfracht;assembly=WFControls"
Title="MainWindow" Height="350" Width="525" SizeChanged="Window_SizeChanged">
<DockPanel>
</DockPanel>
</Window>

Autogrow WPF RichTextBox

You can do the trick with TextBox: when you set AcceptReturn=true, the TextBox will grow as you add new lines of text.
Is it possible to do the same to RichTextBox?
I'm doing this in WPF
Yes. By default, RichTextBox accepts return and will grow accordingly. For example, this RichTextBox will grow:
<Window x:Class="stackoverflow___rich_text_box___accepts_return.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">
<StackPanel>
<RichTextBox/>
</StackPanel>
</Window>
You'd have to do this:
<RichTextBox AcceptsReturn="False"/>
to get it not to grow.

Categories