As the name suggests, I'm trying to create an on/off type button using XAML and PowerShell, but cannot for the life of me find any guides or code on the internet.
I found a page with a great demo. Link here.
This is how the code begins.
<Style TargetType="{x:Type ToggleButton}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Viewbox>
<Border x:Name="Border" CornerRadius="10"
When using XAML for PowerShell we can't utilise x: at all.
Here's another more indepth answer right here on StackOverflow. Same issue. There doesn't seem to be any resources for doing this without the dreaded x:
Anyone any ideas?
U need to copy the style under here:
<Window.Resources>
<Style Key=“MyToggleStyle“ TargetType="ToggleButton">
Then u can use it on your button like this:
<ToggleButton Style="{StaticResource MyToggleStyle}" />
U can simply drop the x:
Name="Border"
TargetType="ToggleButton"
Related
In my .NET MAUI app, I'm implementing chat feature and want to make sure that the Editor and Button are perfectly located at the bottom of the screen.
I created a Grid for the controls to produce this layout
The problem I'm having is with the Editor width because if I get it to look right on Android, it's not perfect on iOS and vice versa.
Here's how I approached it:
<Grid
RowDefinitions="50"
ColumnDefinitions="*,50"
RowSpacing="0"
ColumnSpacing="5"
HorizontalOptions="StartAndExpand"
Margin="5,5,5,5">
<Editor
Grid.Column="0" />
<Button
Grid.Column="1" />
</Grid>
Other than entering some arbitrary number for WidthRequest for the Editor, how do I set the width for it so that it always takes up all the available space and look like it in the picture?
After setting HorizontalOptions="FillAndExpand" as Jason suggested like below, it looks right on Android and iOS.
<Grid
RowDefinitions="50"
ColumnDefinitions="*,50"
RowSpacing="0"
ColumnSpacing="5"
HorizontalOptions="FillAndExpand"
Margin="5">
<Editor
Grid.Column="0" />
<Button
Grid.Column="1" />
</Grid>
I encountered an UI issue when developing an app using MAUI flyoutItem. According to the official doc, it looks like I can only define the flyoutItem appearance by setting two columns(https://learn.microsoft.com/en-us/dotnet/maui/fundamentals/shell/flyout?view=net-maui-7.0): one bind to FlyoutIcon and the other bind to Title.
What if I want to add a third item such as a label for identity/status or a slide button to enable/disable? I expect sth look like this:
[column 0]FlyoutIcon [column 1]Label1 [column 2]Label2/Slide Button
Can you please also show me some sample code for the solution?
Best and Regards
I tried to modify the Grid to add a third column and addition Label but seems not working.
<Shell ...>
...
<Shell.ItemTemplate>
<DataTemplate>
<Grid ColumnDefinitions="0.2*,0.4*,0.4*">
<Image Source="{Binding FlyoutIcon}"
Margin="5"
HeightRequest="45" />
<Label Grid.Column="1"
Text="{Binding Title}"
FontAttributes="Italic"
VerticalTextAlignment="Center" />
<Label Grid.Column="2"
Text="{Binding Text}"
FontAttributes="Italic"
VerticalTextAlignment="End" />
</Grid>
</DataTemplate>
</Shell.ItemTemplate>
</Shell>
Er, guys. Looks like using Menu Item instead of FlyoutItem will resolve the issue.
How can I change the hamburger menu icon in a .NET MAUI app?
I've updated the style of all my icons and I want to change the hamburger menu icon to a custom PNG.
I tried the following in Styles.xaml but that doesn't seem to be the correct property to edit.
<Style TargetType="FlyoutPage">
<Setter Property="IconImageSource" Value="custom_menu_icon.png" />
</Style>
Solution for FlyoutPage
The Flyout of the FlyoutPage is of type ContentPage and thus the icon should be set there instead:
<ContentPage
IconImageSource="custom_menu_icon.png" />
</ContentPage>
You can also define it in the Styles.xaml and assign the style to the page:
<Style TargetType="ContentPage" x:Key="FlyoutStyle">
<Setter Property="IconImageSource" Value="custom_menu_icon.png" />
</Style>
<ContentPage
Style="{StaticResource FlyoutStyle}" />
</ContentPage>
See also: https://learn.microsoft.com/dotnet/maui/user-interface/pages/flyoutpage?view=net-maui-7.0#create-a-flyoutpage
This assumes that you're using the FlyoutPage and not Shell.
Solution for Shell
In case you're using Shell, you can define the style as follows:
<Style TargetType="Shell" ApplyToDerivedTypes="True">
<!-- skipping existing setters here -->
<Setter Property="Shell.FlyoutIcon" Value="custom_menu_icon.png" />
</Style>
See more: https://learn.microsoft.com/dotnet/maui/fundamentals/shell/flyout?view=net-maui-7.0#flyout-icon
in my SAPUI5-application i use breadcrumbs. This feature is quite nice, but on a specific word ("Vertrag") the link to the overriding breadcrumb is collapsed and there's a dropdown-field. By changing the word from "Vertrag" to "Vertrags", the overriding breadcrumb isn't collapsed anymore.
Can you help me, to disaple this dropdown-field?
XML-file containing the breadcrumb:
<FlexBox height="50px" alignItems="Start" justifyContent="Center">
<Breadcrumbs currentLocationText="{i18n>Contract}">
<Link press="onPressBreadcrumb" text="{i18n>Overview}" id="Overview"/>
</Breadcrumbs>
</FlexBox>
OK
Not OK
Thanks.
I think, this must be a issue on calculation width of the flex box. Try to play with margins, pattern or other stuff that affect rendering.
Or try to force for test like this
<FlexBox height="50px" alignItems="Start" justifyContent="Center">
<Breadcrumbs currentLocationText="{i18n>Contract}">
<Link press="onPressBreadcrumb" text="{i18n>Overview}" id="Overview"/>
</Breadcrumbs>
<Label text="AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" />
</FlexBox>
It may be necessary to test it on all popular browsers.
I am working on ECommerce Universal app in Windows 10. I have DatePicker control to manage filter for Between Dates.
It is working fine in Desktop State(View) (>720). But width of DatePicker doesn't reduce in Tablet State(View) (<720).
I have set Setter for it:
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="PageSizeStatesGroup"
CurrentStateChanged="OnCurrentStateChanged">
<VisualState x:Name="MediumState">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="720" />
</VisualState.StateTriggers>
<VisualState.Setters>
<!--Set width to 215 but it doesn't reduce-->
<Setter Target="datepicker1.Width" Value="215"></Setter>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
Generally, this works for other control in my application whether it is for Desktop view or Tablet view or Mobile view. But it doesn't work for DatePicker.
Can anybody suggest me how to achieve this?
DatePicker has also set MinWidth property as default, so you have to join the setter for this property too. Otherwise it takes MinWidth value, when your Width value is smaller.
It should be something like this:
<Setter Target="datePicker1.MinWidth" Value="215" />