following code works fine under Windows 8.1
and I recently upgraded my OS to Windows 10 and it throws an exception.
Here is a screenshot of the exception
This is the XAML code:
<ComboBox Grid.Row="3" HorizontalContentAlignment="Left" HorizontalAlignment="Left"
TabIndex="2" VerticalAlignment="Center"
ItemsSource="{Binding DateFormats}"
SelectedItem="{Binding DateFormatSelected, Mode=TwoWay}">
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Value}" />
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
When I removed the part "SelectedItem" it works but I need the SelectedItem
to be displayed.
Please help.
Here the event viewer application error details. It doesn't provide much info either
Faulting application name: BoardPACWinApp.exe, version: 0.0.0.1, time stamp: 0x55bdb705
Faulting module name: Windows.UI.Xaml.dll, version: 10.0.10240.16397, time stamp: 0x55af0da4
Exception code: 0xc000027b
Fault offset: 0x00722f90
Faulting process id: 0x1e48
Faulting application start time: 0x01d0cd2970f53bb1
Faulting application path: D:\Projects\BoardPACWinApp\BoardPACWinApp\bin\x86\Debug\AppX\BoardPACWinApp.exe
Faulting module path: C:\Windows\System32\Windows.UI.Xaml.dll
Report Id: 38e21b5c-cf75-4849-81df-01bb412c291a
Faulting package full name: IronOneTechnologiesPvtLtd.BoardPACWinDemo_3.14.35.2_x86__na7z394ep8t7e
Faulting package-relative application ID: App
I was getting a similar exception and it was caused because I was manipulating the ItemsSource binding property (List<>) when the binding process started. Now I make all the manipulations on a temp collection which I assign to the binded property when all manipulations to the collection are finished.
Hope this helps...
What I've done is do the SelectedItem binding using the code view.
Here's my XAML code:
<ComboBox x:Name="DateFormatsComboBox" Grid.Row="3" Style="{StaticResource CustomBlueComboBoxStyle}"
ItemsSource="{Binding DateFormats}" ItemContainerStyle="{StaticResource CustomBlueComboBoxItemStyle}">
<!--NOTE: Removed coz Windows 10 had issues | 2015-08-16 | SurenM -->
<!--SelectedItem="{Binding DateFormatSelected, Mode=TwoWay}"-->
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Value}" />
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
Here's my C# code:
//NOTE: Windows 10 had issues with XAML Combobox SelectItem, so it was brought to code behind
DateFormatsComboBox.SelectedItem = _model.DateFormatSelected;
NOTE: _model.DateFormatSelected is a CustomKeyValuePair<string, string>
This approach is tested on Windows 8.1 and Windows 10 both and it works great.
Related
I'm defining a list view as follows:
<ListView Grid.Row="0" Grid.Column="1" ItemsSource="{Binding MenuList}"
SelectedItem="{Binding SelectedEngine, Mode=TwoWay}" SeparatorVisibility="None">
<ListView.RowHeight>
<OnPlatform x:TypeArguments="x:Int32">
<On Platform="Android">52</On>
<On Platform="UWP">154</On>
</OnPlatform>
</ListView.RowHeight>
</ListView>
But I get an error message saying:
No property, bindable property, or event found for 'RowHeight', or mismatching type between value and property.
And if I drop the out it compiles. Does anyone know how I can fix the issue?
I am on VS for Mac v7.4.1 and XF v2.5.0.121934 your code is compiling with enabled XAMLC and working as expected. What is your setup?
Try to update to latest and greatest version of Xamarin.Forms.
I'm trying to implement color picker in uwp using below link
[1]: http://www.c-sharpcorner.com/article/coding4fun-colorpicker-control-in-uwp-with-xaml-and-c-sharp/
but while following process and implementing colorchange event it is giving error "unable to add event handler".Any idea would be appreciated
XAML
xmlns:my="using:Coding4Fun.Toolkit.Controls"
<my:ColorPicker x:Name="W_Paints"
Margin="216,203,-6,0" Height="40"
Width="40" VerticalAlignment="Top"
HorizontalAlignment="Left"/>
I tried to create a color picker with Coding4Fun package by following the above link and the color picker is successfully created with no error on my side.
I used version 2.1.8, and also test version 2.1.7 which also worked. My uwp app target version is build 14393, but I also test with target version 10240. So if you created a uwp app with "Coding4Fun Toolkit - Controls" 2.1.7 or 2.1.8 should be able work well. Here is the demo completing code.
XAML Code
<Page
x:Class="Coding4fun.MainPage"
...
xmlns:my="using:Coding4Fun.Toolkit.Controls" >
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<TextBlock x:Name="tblTitle" HorizontalAlignment="Left" Margin="419,42,0,0" TextWrapping="Wrap" Text="Code4Fun ColorPicker control Demo" VerticalAlignment="Top" Height="37" Width="427" FontSize="24" FontWeight="Bold" />
<Button x:Name="btnCPopen" Content="Open Color Picker" HorizontalAlignment="Left" Margin="110,113,0,0" VerticalAlignment="Top" RenderTransformOrigin="-5.01,1.529" ToolTipService.ToolTip="Open color Picker for changing Background" Click="btnCPopen_Click" />
<Border x:Name="BorCP" BorderBrush="Black" BorderThickness="1" HorizontalAlignment="Left" Height="378" Margin="838,113,0,0" VerticalAlignment="Top" Width="354" />
<my:ColorPicker x:Name="CPtest" HorizontalAlignment="Left" Height="358" Margin="284,113,0,0" VerticalAlignment="Top" Width="374" ColorChanged="CPtest_ColorChanged" Visibility="Collapsed" />
</Grid>
Code behind
private void btnCPopen_Click(object sender, RoutedEventArgs e)
{
CPtest.Visibility = Visibility;
}
private void CPtest_ColorChanged(object sender, Windows.UI.Color color)
{
BorCP.Background = new SolidColorBrush(color);
}
I also upload the demo here you can download for testing and compare what's wrong with your project.
I have a UWP app that needs to get SQL data from a webservice hosted on a .Net server in the cloud as well as some extra data from a web API and I want to show an indeterminate Progress Ring control while it's loading.
I have the control bound to a boolean in my MainViewModel that I set to true at the start of the whole update process (done via an awaited async method which works perfectly) and then to false when all data is downloaded but the ring just never becomes visible. I can see PropertyChanged is getting raised but it makes no difference - the progress ring just never displays.
Here's the thing though - the progress ring IS working, but because I can't get it to display in front of my Hub control it just appears not to be working. I know this because if I move the Hub down 100 pixels and set the vertical alignment of the progress ring to Top I can then see the ring and it behaves exactly as expected. But as I obviously don't want to waste 100 pixels I need to get it to display at the front of all content as you'd expect any progress control to do.
I have also tried putting the ring in the grid of the data template's grid for the middle hub section (there are 3 side by side at 640px each) and in the DataTmeplate itself (the second one in Page.Resources below) but it still won't display it so I am tearing my hair out.
I know this has got to be the simplest XAML issue but I've tried everything I can think of and searched the web so I'm hoping someone else can help me get the progess ring to display in front of the Hub?
Here's a cut down version of my XAML page - I can post the lot but it's a big page.
<Page
x:Class="TVTracker.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:TVTracker"
xmlns:vm="using:TVTracker.ViewModel"
xmlns:model="using:TVTracker.Model"
xmlns:hlp="using:TVTracker.Common"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
RequestedTheme="Light">
<Page.DataContext>
<vm:MainViewModel/>
</Page.DataContext>
<Page.Resources>
<!-- styles and other resources here -->
<!-- gets displayed in first of 3 hub sections 640 wide -->
<DataTemplate x:Key="ShowListTemplate" x:DataType="model:TVShow">
<Grid Width="640" Height="Auto" Margin="5" HorizontalAlignment="Stretch" RightTapped="ShowsList_RightTapped">
<!-- ...etc etc... -->
<\DataTemplate>
<!-- gets displayed in second of 3 hub sections 640 wide -->
<DataTemplate x:Key="DetailsTemplate" x:DataType="model:TVShow">
<Grid Width="640" Margin="0,20,0,0" Height="Auto" VerticalAlignment="Top" HorizontalAlignment="Stretch">
<!-- ...etc etc... -->
</Grid>
</DataTemplate>
<!-- gets displayed in second of 3 hub sections 640 wide -->
<DataTemplate x:Key="EpisodeListTemplate" x:DataType="model:Episode">
<Grid Width="640" Margin="0,20,0,0" Height="Auto" VerticalAlignment="Top" HorizontalAlignment="Stretch">
<!-- ...etc etc... -->
</Grid>
</DataTemplate>
</Page.Resources>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<ProgressRing Name="pgbLoadingShow" IsActive="{Binding LoadingShowData}" Width="100" Height="100" VerticalAlignment="top" Foreground="{StaticResource Medium}"/>
<Hub SectionHeaderClick="Hub_SectionHeaderClick" Margin="0,0,0,0" HorizontalContentAlignment="Stretch" Background="{StaticResource Dark}">
<Hub.Header>
<TextBlock Text="ShowTracker" FontSize="14" Foreground="{StaticResource Bright}"/>
</Hub.Header>
<HubSection Name="hsShows" MinWidth="640" Padding="20" VerticalAlignment="Top" Background="{StaticResource Dark}" >
<!-- ...etc etc.. -->
</HubSection>
<!-- two other hubsections here -->
</Hub>
</Grid>
</Page>
Have you tried putting the ProgressRing after the Hub in your XAML?
<Hub/>
<ProgressRing/>
Generally it will be displayed in the order which you put them in, so the ProgressRing element will be behind the Hub with your code.
I am creating an app in Lightswitch and I used this custom control.
The problem is when I change value of the control.
It's probably not possible to change control dynamically, it must be refreshed to get new value.
So I need to know how can I refresh just control or part of the screen.
This is how the control code look
<Grid x:Name="LayoutRoot" Background="White" Width="200" Height="200">
<GaugeControl:GaugeControl HorizontalAlignment="Left" Margin="10,10,10,10"
Name="gaugeControl1"
Maximum="25000" Minimum="0" VerticalAlignment="Top" />
</Grid>
This way is how I set binding to the value
public RadioGauge() {
InitializeComponent();
gaugeControl1.Value = Amount.amount; // where Amount is class and amount is int property
}
And this way I change the control property
SilverlightCustomControls.Amount.amount = 10000;
I couldnt find anything about refreshing or reloading XAML control or refreshing just part of lighswitch screen.. thx for any help
Lightswitch automatically refreshes components if they are data bound. Because you are just setting the value, the control is not being refreshed. Can you not bind the control to your property? Then when you change it in code the control should automatically refresh?
<Grid x:Name="LayoutRoot" Background="White" Width="200" Height="200">
<GaugeControl:GaugeControl HorizontalAlignment="Left" Margin="10,10,10,10"
Name="gaugeControl1"
Maximum="25000" Minimum="0"
VerticalAlignment="Top"
Value="{Binding Screen.SCREENDATASET.SelectedItem.Amount}" />
</Grid>
I am developing an windows 8 App in which I have placed a combobox inside dev express windows8 grid control.I can populate the Date for the combobox and I can save the selectionitem in database. But when I am loading it again the previously selected value in the combo box is not getting defaulted.
<DataTemplate >
<ComboBox x:Name="cNumber" SelectedValuePath="id" DisplayMemberPath="value"
SelectedValue="{Binding Path=AreaSeq, Mode=TwoWay}" Loaded="cNumber_Loaded_1"
Height="30" Width="60" Tag="{Binding AreaId}"
Style="{StaticResource ComboBoxStyle1}"
SelectionChanged="ComboBox_SelectionChanged_1" />
</DataTemplate>
In Loaded function I am populating my grid and in selectionchanged I am storing its value.