moonlight vs. silverlight :: datagrid incompatibility? - c#

I'm trying to develop an application in moonlight. Now I'm trying to use a DataGrid to show some data.
In an old silverlight project I used a DataGrid in this way:
<UserControl x:Class="One.Page"
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"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400"
xmlns:my="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data">
<Grid x:Name="LayoutRoot" Background="White">
<StackPanel Orientation="Vertical">
<TextBlock x:Name="lbl1">lblInfo1</TextBlock>
<TextBlock x:Name="lbl2">lblInfo2</TextBlock>
<TextBox x:Name="txt1">Write here</TextBox>
<Button x:Name="btn1" Content="Send" Click="btn1_Click" />
<my:DataGrid x:Name="grData"
Grid.Row="1"
Width="500" Height="250"
Margin="10"
AutoGenerateColumns="False">
<my:DataGrid.Columns>
<my:DataGridTextColumn Header="Código" />
<my:DataGridTextColumn Header="Lote" />
<my:DataGridTextColumn Header="Ciudad" />
<my:DataGridTextColumn Header="País" />
</my:DataGrid.Columns>
</my:DataGrid>
</StackPanel>
</Grid>
</UserControl>
but if I use the same code in my new moonlight project I get an empty page. I've been looking for some examples and I found a simple one:
http://geeks.ms/blogs/lmblanco/archive/2008/09/02/silverlight-datagrid-crear-una-columna-a-partir-de-varios-valores.aspx
Is this example the writer use the DartaGrid in the same way than me. Can anyone explain me why in VS2010 I can use this code and In monodevelop 2.4 or monodevelop 2.8 I can't?

According to some research on Google, it looks like your project needs additional dependencies and MonoDevelop isn't notifying you: http://mono.1490590.n4.nabble.com/Moonlight-datagrid-support-td1836948.html

Related

C# UWP: The parameter is incorrect - NavigationView

I'm building a UWP in C# with Visual Studio, and need to hide and show a NavigationView, named 'navigationView' as required.
I am using the property .IsPaneVisible to achieve this, but am encountering a strange bug:
I can set IsPaneVisible = true or false in the xaml document, but if I set navigationView.IsPaneVisible = false; in the related C# document, and run a debug build of the app from Visual Studio, the app crashes with the error
System.ArgumentException: 'The parameter is incorrect.
Even stranger, if I run the same debug build, but launched directly, outside Visual Studio, the app functions normally without crashing at this line.
Does anyone have an idea of why this might be happening or how I could fix it?
Here's the xaml code:
<Page
x:Class="Sheet_Music_Reader.Views.ShellPage"
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:i="using:Microsoft.Xaml.Interactivity"
xmlns:behaviors="using:Sheet_Music_Reader.Behaviors"
xmlns:winui="using:Microsoft.UI.Xaml.Controls"
xmlns:helpers="using:Sheet_Music_Reader.Helpers"
xmlns:views="using:Sheet_Music_Reader.Views"
Loaded="OnLoaded"
mc:Ignorable="d">
<Page.Resources>
<!--This top margin is the height of the custom TitleBar-->
<Thickness x:Key="NavigationViewContentMargin">0,48,0,0</Thickness>
<Thickness x:Key="NavigationViewContentGridBorderThickness">0</Thickness>
<SolidColorBrush x:Key="NavigationViewContentBackground" Color="Transparent"></SolidColorBrush>
</Page.Resources>
<Grid>
<Border x:Name="AppTitleBar"
IsHitTestVisible="True"
VerticalAlignment="Top"
Background="Transparent"
Height="40"
Canvas.ZIndex="1"
Margin="48,8,0,0">
<StackPanel Orientation="Horizontal">
<Image x:Name="AppFontIcon"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Source="Assets/Square44x44Logo.png"
Width="16"
Height="16"/>
<TextBlock x:Name="AppTitle"
Text="enScore"
VerticalAlignment="Center"
Margin="12,0,0,0"
Style="{ThemeResource CaptionTextBlockStyle}"/>
</StackPanel>
</Border>
<winui:NavigationView
IsBackButtonVisible="Visible"
IsBackEnabled="{x:Bind IsBackEnabled, Mode=OneWay}"
SelectedItem="{x:Bind Selected, Mode=OneWay}"
ItemInvoked="OnItemInvoked"
IsSettingsVisible="True"
IsTitleBarAutoPaddingEnabled="False"
DisplayModeChanged="NavigationViewControl_DisplayModeChanged"
Canvas.ZIndex="0"
x:Name="navigationView">
<winui:NavigationView.MenuItems>
<winui:NavigationViewItem x:Uid="Shell_Main" Icon="Copy" helpers:NavHelper.NavigateTo="views:MainPage" />
</winui:NavigationView.MenuItems>
<i:Interaction.Behaviors>
<behaviors:NavigationViewHeaderBehavior
DefaultHeader="{x:Bind Selected.Content, Mode=OneWay}">
<behaviors:NavigationViewHeaderBehavior.DefaultHeaderTemplate>
<DataTemplate>
<Grid x:Name="headerGrid">
<TextBlock
Text="{Binding}"
Style="{ThemeResource TitleTextBlockStyle}"
Margin="{StaticResource SmallLeftRightMargin}" />
<Button Style="{ThemeResource ButtonRevealStyle}" Content="Refresh Library Contents" HorizontalAlignment="Right" Margin="0,45,8,0" Click="RefreshLibrary"/>
<Button Style="{ThemeResource ButtonRevealStyle}" Content="Import PDF To Current Folder" HorizontalAlignment="Right" Margin="0,-35,140,0" Click="AddScore"/>
<Button Style="{ThemeResource ButtonRevealStyle}" Content="Add New Folder" HorizontalAlignment="Right" Margin="0,-35,8,0" Click="AddFolderAsync"/>
<ToggleButton Style="{ThemeResource ToggleButtonRevealStyle}" x:FieldModifier="public" x:Name="tbtndelete" Content="Delete Items" HorizontalAlignment="Right" Margin="0,45,191,0" Tapped="DeleteItem"/>
</Grid>
</DataTemplate>
</behaviors:NavigationViewHeaderBehavior.DefaultHeaderTemplate>
</behaviors:NavigationViewHeaderBehavior>
</i:Interaction.Behaviors>
<Grid>
<Frame x:Name="shellFrame" />
</Grid>
</winui:NavigationView>
</Grid>
</Page>
Try to change the placement of the menu with:
PaneDisplayMode="Top"
For my case with Microsoft.UI.Xaml.Controls for Microsoft.WindowsAppSDK v1.0.0.
the showing/hidding of menu bar works fine.
Left, LeftMinimal, LeftCompact crashes the app.
I know you may expect the menu on the left, but still on the top is not that bad idea ;-) At least it works.. Greetz.

How to select a TextBox with gaze?

I want to build a "gaze enabled" app, where most controls could be activated just using one's gaze.
Doing that with a button is pretty easy. Just add gaze:GazeInteraction.Interaction = Enable to the button in XAML and when I dwell at it it's as if I've clicked on it with the cursor.
But it doesn't work with a TextBox that way. Maybe I should do something from code-behind?
I'm still a beginner with C# and I've already read this, but I coldn't understand it well, so I used that instead.
Here's my code so far:
<Page
x:Class="gazebox.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:gazebox"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:gaze="using:Microsoft.Toolkit.Uwp.Input.GazeInteraction"
Width="500" Height="250">
<Grid Background="#FF1A3163" VerticalAlignment="Stretch">
<Button Content="Exit" HorizontalAlignment="Right" Margin="0,0,25,0" Height="100" Width="100" Background="#66E8E5E5" gaze:GazeInput.Interaction="Enabled"/>
<TextBox x:Name="textBox" Text="" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Top" Height="50" Width="200" Margin="25,150,0,0" gaze:GazeInput.Interaction="Enabled"/>
<TextBox x:Name="textBox2" Text="" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Top" Height="50" Width="200" Margin="25,50,0,0"/>
</Grid>
</Page>
and my .cs file is pretty much empty yet.
So, how do I make the TextBox(or any other element for that matter) be clicked when I dwell at it?
Any help would be greatly appreciated.
Pavel
p.s. I have a Tobii eye tracker

ChangePropertyAction behaviour does not work on Popup with a custom control

Hi i have the following window, it has a button, and when i click on it, it shows a popup that contains some text. When the popup is closed, the behaviour cleans the text inside the popup
<Window
x:Class="WpfTests.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:behaviours="http://schemas.microsoft.com/xaml/behaviors"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WpfTests"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="MainWindow"
Width="300"
Height="300"
mc:Ignorable="d">
<StackPanel
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Background="Red"
Orientation="Vertical">
<ToggleButton
x:Name="CustomButton"
Width="40"
Height="40"
Content="Checkbutton" />
<Popup
IsOpen="{Binding ElementName=CustomButton, Path=IsChecked}"
Placement="Bottom"
PlacementTarget="{Binding ElementName=CustomButton}"
StaysOpen="False">
<behaviours:Interaction.Triggers>
<behaviours:EventTrigger EventName="Closed">
<behaviours:ChangePropertyAction
PropertyName="Text"
TargetObject="{Binding ElementName=UrlTextBox}"
Value="" />
</behaviours:EventTrigger>
</behaviours:Interaction.Triggers>
<TextBlock
x:Name="UrlTextBox"
Width="100"
Height="100"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="Green"
Foreground="White"
Text="A url" />
</Popup>
</StackPanel>
Now, if i change the child of the popup to a user control like the following:
<Popup
IsOpen="{Binding ElementName=CustomButton, Path=IsChecked}"
Placement="Bottom"
PlacementTarget="{Binding ElementName=CustomButton}"
StaysOpen="False">
<behaviours:Interaction.Triggers>
<behaviours:EventTrigger EventName="Closed">
<behaviours:ChangePropertyAction
PropertyName="Text"
TargetObject="{Binding ElementName=CustomControl, Path=UrlTextBox}"
Value="" />
</behaviours:EventTrigger>
</behaviours:Interaction.Triggers>
<local:CustomControl x:Name="CustomControl" />
</Popup>
CustomControl:
<UserControl
x:Class="WpfTests.CustomControl"
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:local="clr-namespace:WpfTests"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
<TextBlock
x:Name="UrlTextBox"
Width="100"
Height="100"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="Green"
Foreground="White"
Text="A url" />
The behaviour crashes, because it cannot find the property text and i don't know why.
I know i can do this using code behind, but i would like to do it in the xaml.
Any help would be appreciated
This line isn't going to work
TargetObject="{Binding ElementName=CustomControl, Path=UrlTextBox}"
Because the Path part needs to point to a Property (the TextBlock inside the UserControl is compiled as a public field).
You need to add a line in you UserControl code-behind like this:
public TextBlock UrlText => this.UrlTextBox;
and then in your behaviour change it to this
TargetObject="{Binding ElementName=CustomControl, Path=UrlText}"

Telerik controls windows phone 8.1

Trying to implement a conversation view in a wp8.1 app using telerik controls, a platform im not familiar with. I keep getting a reference error on build:
Error 3 The name "RadPointerContentControl" does not exist in the namespace "clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Primitives". D:\Visual Studio Workspace\Sports App\Sports App Prototype\Sports App Prototype\MainPage.xaml 74 29 Sports App Prototype
This error is really confusing me. I have referenced
xmlns:telerikPrimitives="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Primitives"
in the XAML document but cannot seem to get it working properly, as if its just not seeing the reference properly, or is missing it at build time, tbh i havent a clue!
Any help would be much appreciated.
EDIT: XAML
<Page xmlns:Maps="using:Windows.UI.Xaml.Controls.Maps"
x:Class="Sports_App_Prototype.MainPage"
xmlns:primitives="clr-namespace:Telerik.Windows.Controls.Primitives;assem‌​bly=Telerik.Windows.Controls.Primitives"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Sports_App_Prototype"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
<Pivot>
<Flyout x:Name="registration" >
<Grid Height="320">
<TextBlock Margin="0,0,0,309">
Register New User or Login
</TextBlock>
<TextBox Margin="10,59,10,0" Text="Password">
</TextBox>
<TextBox Margin="10,16,10,0" Text="Username">
</TextBox>
<CheckBox Margin="172,99,0,0" Content="Accept">
</CheckBox>
<Button Content="Register/Login" Margin="10,99,0,164">
</Button>
</Grid>
</Flyout>
<PivotItem Header="map view">
<StackPanel>
<Maps:MapControl Height="450" Width="355" />
<Button x:Name="FilterButton" HorizontalAlignment="Center" Click="Filter_Click" Content="Filter" Margin="126,0,126.667,0" Height="61"/>
</StackPanel>
</PivotItem>
<Flyout x:Name="Filter">
<Grid>
<StackPanel>
<TextBlock>
Filter Users
</TextBlock>
<RichTextBlock>
<!-- Stuff goes here for RTB -->
</RichTextBlock>
<CheckBox>
Dynamically generated from user #1
</CheckBox>
<CheckBox>
Dynamically generated from user #2
</CheckBox>
<CheckBox>g
Dynamically generated from user #3
</CheckBox>
<CheckBox>
Dynamically generated from user #4
</CheckBox>
</StackPanel>
</Grid>
</Flyout>
<PivotItem Header="chat">
<DataTemplate>
<Grid Margin="12">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<telerikPrimitives:RadPointerContentControl Background="{StaticResource PhoneAccentBrush}"
TargetPoint="-150,-300">
<telerikPrimitives:RadPointerContentControl.PointerTemplate>
<DataTemplate>
<Polygon Width="12"
Height="24"
Points="0,0 12,0 12,12 0,24"
StrokeThickness="0"
Fill="{StaticResource PhoneAccentBrush}"
RenderTransformOrigin="0.5, 0.5">
<Polygon.RenderTransform>
<ScaleTransform ScaleX="-1"/>
</Polygon.RenderTransform>
</Polygon>
</DataTemplate>
</telerikPrimitives:RadPointerContentControl.PointerTemplate>
<StackPanel>
<TextBlock Text="{Binding Path=Text}"
TextWrapping="Wrap"
Margin="12"/>
<TextBlock Text="{Binding Path=TimeStamp}"
Margin="12, 0, 12, 12"
HorizontalAlignment="Right"/>
</StackPanel>
</telerikPrimitives:RadPointerContentControl>
</Grid>
</DataTemplate>
</PivotItem>
</Pivot>
</Grid>
This is complaining that it cannot find the reference to the .DLL. Under references in Visual Studio, do you have the file called Telerik.Windows.Controls.Primitives added? If so, then please post your entire XAML file and I'll help you troubleshoot it.
BTW, make sure you are using a Silverlight WP8.1 app and not a WinRT app.

issue in watermark textbox

I am new to wpf.I downloaded the wpf toolkit and then added it's dll file into my project file.Then tried some code to create watermark textbox but showing error(The tag 'WatermarkTextBox' does not exist in XML namespace).
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
x:Class="TRAINING.WaterMark"
x:Name="Window"
Title="WaterMark"
Width="640" Height="480">
<extToolkit:WatermarkTextBox>
<extToolkit:WatermarkTextBox.Watermark>
<StackPanel Orientation="Horizontal">
<Image Source="Contact16.png" Stretch="None" />
<TextBlock Text="Enter First Name" Margin="4,0,0,0" />
</StackPanel>
</extToolkit:WatermarkTextBox.Watermark>
</extToolkit:WatermarkTextBox>
</Window>
Please help.
I have not used the wpf toolkit before, but I'm pretty sure that as you have added the namespace using xctk, then you should use that in the xaml - i.e. xctk:WatermarkTextBox instead of extToolkit:WatermarkTextbox
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
x:Class="TRAINING.WaterMark"
x:Name="Window"
Title="WaterMark"
Width="640" Height="480">
<extToolkit:WatermarkTextBox>
<extToolkit:WatermarkTextBox.Watermark>
<StackPanel Orientation="Horizontal">
<Image Source="Contact16.png" Stretch="None" />
<TextBlock Text="Enter First Name" Margin="4,0,0,0" />
</StackPanel>
</extToolkit:WatermarkTextBox.Watermark>
</extToolkit:WatermarkTextBox>
</Window>
I Guess You Missed the refrence of that extToolkit so i added. i hope it will help you
My reason for this issue was confusion between xceed ($) vs dotnetprojects (Free) NuGet package.
So once I uninstalled the xceed, everything was working fine and error was resolved.

Categories