Can WidthRequest be converted or overwritten depending on Device type(Tablet, phone or Desktop)? [closed] - xaml

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 months ago.
Improve this question
My IOS Application utilize WidthRequest all over my XAML code and would like to know if there is a faster way on overwriting or converting each fixed WidthRequest value depending on the Device?
The easiest way is to put OnIdiom in every code but will take more time to code. Example I need to do the example code below 200+ times which will take a lot of time
From :
<Button WidthRequest="500"
Text="CLOSE"
FontSize="Large"
Command="{Binding CancelCommand}"
TextColor="White"/>
To :
<Button Text="CLOSE"
FontSize="Large"
Command="{Binding CancelCommand}"
TextColor="White" >
<Button.WidthRequest>
<OnIdiom x:TypeArguments="x:Double">
<OnIdiom.Phone>250</OnIdiom.Phone>
<OnIdiom.Tablet>500</OnIdiom.Tablet>
</OnIdiom>
</Button.WidthRequest>

Related

I am looking for the materializecss datetimepicker like bootstrap datetimepicker [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 1 year ago.
Improve this question
Hi I am trying to looking for materializecss datetimepicker, In official materializecss.com also I am not getting the datetimepicker only getting the timepicker and datepicker but i am not looking for that only I need like bootstarpdatetimepicker in the materializecss.
So kindly help me on this issue.
Ok , here is the direct code.
<mat-form-field appearance="fill">
<mat-label>Choose a date</mat-label>
<input matInput [matDatepicker]="picker">
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker #picker></mat-datepicker>
</mat-form-field>
and here is the link for future reference. https://material.angular.io/components/datepicker/overview

Windows phone toolkit ListPicker only allowing 5 elements

I have a simple working example:
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<toolkit:ListPicker>
<toolkit:ListPickerItem Content="FIRST" />
<toolkit:ListPickerItem Content="SECOND" />
<toolkit:ListPickerItem Content="THIRD" />
<toolkit:ListPickerItem Content="FOURTH" />
<toolkit:ListPickerItem Content="FIFTH" />
<toolkit:ListPickerItem Content="SIXTH" />
</toolkit:ListPicker>
</Grid>
create a new windows phone 8 app, install the windows phone toolkit nuget package, then add only the listpicker as shown above. It will blow. But, if you delete the sixth ListPickerItem, then it works.
Has anyone else gotten the listpicker to work? Do I need to add the items in code to get this to work?
by default list picker only allow 5 elements to show on the same view if it is more than that it will show it will take a full single view to show the elements and for that you have to add the elements from code behind. or you can change ItemCountThreshold.
The answer from souvickcse is not working anymore, because ItemCountThreshold is read-only now. Here's a "hack" which will work. Replace "ListPicker" with the Name you have given to your listpicker.
ListPicker.SetValue(Microsoft.Phone.Controls.ListPicker.ItemCountThresholdProperty, 100);

How to reuse XAML code blocks without binding?

I have this XAML code block:
<StackPanel Orientation="Horizontal">
<TextBlock Text="Hello " />
<TextBlock Text="World" />
</StackPanel>
I would like to define this block (for example in /Common/CustomStyles.xaml) to include it on different XAML pages. How does it work?
I do not need a DataTemplate or something similar because the text is static.
You could put it in a user control and re-use it that way. If it's just the text you are interested in then you could use a resource file - this would update the textbox on any screen as long as it had the right uid.

Windows 8 bottom app bar

I've been trying to get an App bar implemented in a WinRT metro app (C# / XAML), but don't know where to begin. I've tried using the <ApplicationBar/> tag and I get a Type not found error.
There's no help online, could someone update this post with the answer so that it'll serve as a reference to other programmers as well?
There's only a JavaScript sample which isn't of much help.
This should work:
<AppBar
VerticalAlignment="Bottom">
<Button
AutomationProperties.Name="Play"
Style="{StaticResource PlayAppBarButtonStyle}"
Command="{Binding PlayCommand}" />
</AppBar>
– you would put that in the layout root grid of your page.
*EDIT
Note: According to documentation - you should put it in Page.BottomAppBar property, although at least in Windows 8 Consumer Preview - it works fine when used in any Grid, which is convenient if your UI isn't tightly coupled to a Page control.
*EDIT 2, response from MSFT:
The recommended approach is to use the Page.BottomAppBar/TopAppBar properties.
There are known hit-testing issues in the Consumer Preview if AppBars are added without using these properties
The AppBars do not use the proper animations if they are added without using these properties
If AppBars are added as children of arbitrary elements then it's easier for multiple controls to attempt to create/modify AppBars, resulting in an inconsistent user experience
*EDIT 3
The CustomAppBar in WinRT XAML Toolkit can be used anywhere, animates based on Vertical/Horizontal-Alignment, can have other content overlaid on top of it and also has a CanOpen property that allows to block it from opening.
<Page.TopAppBar>
<AppBar>
<TextBlock x:Name="TextBlock1" Text="Sample Text" Margin="0,0,0,0" Height="Auto" VerticalAlignment="Center" HorizontalAlignment="Left"/>
</AppBar>
</Page.TopAppBar>

Closing nested tabs using WPF?

I'm trying to design a UI that contains nested tabs, but I can't seem to find information on how to remove the nested tabs in an MVVM fashion.
Here's my XAML (snipped for brevity):
<TabControl Name="ProjectTabControl" DockPanel.Dock="Top" ItemsSource="{Binding ProjectTabs}" IsSynchronizedWithCurrentItem="True">
<TabControl.ContentTemplate>
<DataTemplate>
<TabControl DockPanel.Dock="Top" ItemsSource="{Binding FileTabs}" Padding="1">
<Button Command="{Binding CloseTabCommand}" CommandParameter="TabItem" />
</TabControl>
</DataTemplate>
</TabControl.ContentTemplate>
</TabControl>
My question is: what argument(s?) should I be passing in CommandParameter, and how would I affect it in the ViewModel to properly remove the tab?
It doesn't look like you have a solid understanding of how to implement an M-V-VM pattern in WPF. It looks like you know understand DataBinding but the pattern your sample demonstrates seems to be missing an understand of ViewModels and Commands, which are really required for MVVM.
Review the article linked below and the sample application it uses. You should find what you're looking to do is demonstrated here and is pretty easy to implement.
The Model-View-ViewModel (MVVM) Design Pattern for WPF
I hope that this doesn't seem like a cop-out but it would require a significant amount of re-posting of the linked article to get you where you want to go. Go read the article, work through the sample and if you still have problems, post on this question and I'll make sure to watch for it.