WPF Dockpanel width Stretch in xaml - c#

I have a toolbox and want to make fill. But I dont make to this. İt is simple problem, I know that because I tried very hard but it did not.
<StackPanel Orientation="Vertical" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="1" Grid.Row="0">
<DockPanel Height="40" HorizontalAlignment="Stretch" Background="#eaeaea" LastChildFill="True">
<StackPanel HorizontalAlignment="Stretch" DockPanel.Dock="Left" Orientation="Vertical">
<Border BorderThickness="1" BorderBrush="#eaeaea" CornerRadius="10" Padding="2" VerticalAlignment="Stretch" >
<Grid Width="auto" HorizontalAlignment="Stretch" >
<Border Name="mask" Background="#eaeaea" CornerRadius="6,0,0,6" HorizontalAlignment="Stretch" />
<StackPanel Height="30" Margin="2,2,2,2" Name="kucukmenu" HorizontalAlignment="Stretch" Width="auto">
<StackPanel.OpacityMask>
<VisualBrush Visual="{Binding ElementName=mask}"/>
</StackPanel.OpacityMask>
</StackPanel>
</Grid>
</Border>
</StackPanel>
<StackPanel Height="40" Orientation="Horizontal" HorizontalAlignment="Right" DockPanel.Dock="Right">
<Button Style="{DynamicResource systembtn}">
<Image Source="images/icons/settings.png" HorizontalAlignment="Right"/>
</Button>
<Button Style="{DynamicResource systembtn}">
<Image Source="images/icons/minimize.png" HorizontalAlignment="Right" />
</Button>
<Button Style="{DynamicResource systembtn}">
<Image Source="images/icons/cancel.png" HorizontalAlignment="Right"/>
</Button>
</StackPanel>
</DockPanel>
</StackPanel>
Now it looks like this
I want to this

You can simply use Grid with ColumnDefinitions
Width="*" means fills as much as area an item can, this is for your blue area
Width="Auto" means only fills area an item need so this is for your buttons
You can find more information by searching xaml grid
<Grid Height="40">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<DockPanel Grid.Column="0" Width="100">
<StackPanel HorizontalAlignment="Stretch" DockPanel.Dock="Left" Orientation="Vertical">
<StackPanel.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<LinearGradientBrush.RelativeTransform>
<TransformGroup>
<ScaleTransform CenterY="0.5" CenterX="0.5" />
<SkewTransform CenterY="0.5" CenterX="0.5" />
<RotateTransform Angle="90" CenterY="0.5" CenterX="0.5" />
<TranslateTransform />
</TransformGroup>
</LinearGradientBrush.RelativeTransform>
<GradientStop Color="#FFBFC5E2" Offset="0" />
<GradientStop Color="#FF123CF5" Offset="1" />
</LinearGradientBrush>
</StackPanel.Background>
</StackPanel>
</DockPanel>
<Button Grid.Column="1" Content="btn 1" />
<Button Grid.Column="2" Content="btn 2" />
<Button Grid.Column="3" Content="btn 3" />
</Grid>
If you need more complex things to do, you can use this package https://github.com/sourcechord/GridExtra

Related

How do I keep Richtext box from expanding?

I have a RichTextBox inside my application, and as I add text to it, the text box expands vertically. I want it to dynamically size if the application is stretched, but not expand if text is added to it.
Here is my ALL of my xaml code:
<Grid Background="#FF1F1F1F">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Border Grid.Row="0" BorderThickness="1" Padding="5" Margin="10,10,10,0" BorderBrush="#FF878383" CornerRadius="10">
<Border.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="0" />
<GradientStop Color="#FF323232" Offset="1" />
</LinearGradientBrush>
</Border.Background>
<Grid UseLayoutRounding="True">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<Label Content="Server: " VerticalAlignment="Stretch" VerticalContentAlignment="Center" HorizontalAlignment="Left" Padding="0" Margin="3" Foreground="White" />
<Label x:Name="ServerIDLabel" Content="" VerticalAlignment="Stretch" VerticalContentAlignment="Center" HorizontalAlignment="Left" Padding="0" Margin="3" Foreground="White" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="Port: " VerticalAlignment="Stretch" VerticalContentAlignment="Center" HorizontalAlignment="Left" Padding="0" Margin="3" Foreground="White" />
<Label Name="txtPort" Content="10037" VerticalAlignment="Center" Width="60" HorizontalAlignment="Center" Margin="3" Foreground="White" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="IP:" VerticalAlignment="Stretch" VerticalContentAlignment="Center" HorizontalAlignment="Left" Padding="0" Margin="3" Foreground="White" />
<Label Name="IPAddress" Content="255.255.255.255" VerticalAlignment="Center" Margin="3" Foreground="White" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="Version:" VerticalAlignment="Stretch" VerticalContentAlignment="Center" HorizontalAlignment="Left" Padding="0" Margin="3" Foreground="White" />
<Label Name="lblVersionNumber" Content="3.0.0.0" VerticalAlignment="Center" Margin="3" Foreground="White" />
</StackPanel>
</StackPanel>
<Border Grid.Column="1" BorderThickness="1" Padding="5" BorderBrush="#FF878383" CornerRadius="10">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<StackPanel Orientation="Horizontal">
<TextBlock x:Name="ManagerNoticeLabel" Text="Notifications:" TextWrapping="Wrap" Foreground="White" />
<Button Margin="25,0" x:Name="ClearManagerNotifications" Content="Clear" Click="ClearManagerNotifications_Click" />
</StackPanel>
</Grid>
<Grid Grid.Row="1">
<DockPanel >
<RichTextBox Name="ManagerNotice" Background="#FF343434" Foreground="#FFDEDEDE" >
<RichTextBox.Resources>
<Style TargetType="{x:Type Paragraph}">
<Setter Property="Margin" Value="0"/>
</Style>
</RichTextBox.Resources>
</RichTextBox>
</DockPanel>
</Grid>
</Grid>
</Border>
<StackPanel Orientation="Vertical" Grid.Column="2" >
<Button Name="btnStartServer" Content="Start" VerticalAlignment="Center" Margin="10" Click="btnStartServer_Click"></Button>
<Button Name="btnStopServer" Content="Stop" VerticalAlignment="Center" Margin="10" Click="btnStopServer_Click" IsEnabled="False" />
</StackPanel>
</Grid>
</Border>
<my:VersionDisplayControl Grid.Row="1" x:Name="versionDisplayControl" Margin="10,10,10,0" />
<my:AgentActionsControl Grid.Row="2" x:Name="agentActionsControl" Margin="10,10,10,0" />
<Border Grid.Row="3" BorderThickness="1" Padding="5" Margin="10" BorderBrush="#FF878383" CornerRadius="10">
<Border.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="0" />
<GradientStop Color="#FF323232" Offset="1" />
</LinearGradientBrush>
</Border.Background>
<Grid>
<Grid Grid.Column="0">
<Grid.RowDefinitions>
<RowDefinition Height="28"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Orientation="Horizontal" Margin="0,0,5,0" x:Name="Summary_Agents">
<Label x:Name="AgentsLabel" Content="Agents:" Foreground="Lime" FontWeight="Normal" FontSize="13" FontStyle="Normal" FontStretch="Normal" />
<Label Content="0" x:Name="lblAgentCount" Foreground="Lime" FontWeight="Normal" FontSize="13" FontStyle="Normal" FontStretch="Normal" />
<Label x:Name="OfLabel" Content="of" Foreground="Lime" FontWeight="Normal" FontSize="13" FontStyle="Normal" FontStretch="Normal" />
<Label Content="0" x:Name="lblMaxAgentCount" Foreground="Lime" FontWeight="Normal" FontSize="13" FontStyle="Normal" FontStretch="Normal" />
</StackPanel>
<StackPanel Grid.Column="1" Orientation="Horizontal" Margin="5,0" x:Name="Summary_HardwareInventory" >
<Label x:Name="HdInvLabel" Content="Hard Inv" Foreground="Lime" FontWeight="Normal" FontSize="13" FontStyle="Normal" FontStretch="Normal" />
<Label Content="0" x:Name="lblHdInvCount" Foreground="Lime" FontWeight="Normal" FontSize="13" FontStyle="Normal" FontStretch="Normal" />
<Label x:Name="OfHdInvLabel" Content="of" Foreground="Lime" FontWeight="Normal" FontSize="13" FontStyle="Normal" FontStretch="Normal" />
<Label Content="0" x:Name="lblHdInvCountMax" Foreground="Lime" FontWeight="Normal" FontSize="13" FontStyle="Normal" FontStretch="Normal" />
</StackPanel>
<StackPanel Grid.Column="2" Orientation="Horizontal" Margin="5,0" x:Name="Summary_SoftwareInventory" >
<Label x:Name="SfInvLabel" Content="Soft Inv" Foreground="Lime" FontWeight="Normal" FontSize="13" FontStyle="Normal" FontStretch="Normal" />
<Label Content="0" x:Name="lblSfInvCount" Foreground="Lime" FontWeight="Normal" FontSize="13" FontStyle="Normal" FontStretch="Normal" />
<Label x:Name="OfSfInvLabel" Content="of" Foreground="Lime" FontWeight="Normal" FontSize="13" FontStyle="Normal" FontStretch="Normal" />
<Label Content="0" x:Name="lblSfInvCountMax" Foreground="Lime" FontWeight="Normal" FontSize="13" FontStyle="Normal" FontStretch="Normal" />
</StackPanel>
<StackPanel Grid.Column="3" Orientation="Horizontal" Margin="5,0" x:Name="Summary_E2P">
<Label x:Name="E2InvLabel" Content="E2P" Foreground="Lime" FontWeight="Normal" FontSize="13" FontStyle="Normal" FontStretch="Normal" />
<Label Content="0" x:Name="lblE2InvCount" Foreground="Lime" FontWeight="Normal" FontSize="13" FontStyle="Normal" FontStretch="Normal" />
<Label x:Name="OfE2InvLabel" Content="of" Foreground="Lime" FontWeight="Normal" FontSize="13" FontStyle="Normal" FontStretch="Normal" />
<Label Content="0" x:Name="lblE2InvCountMax" Foreground="Lime" FontWeight="Normal" FontSize="13" FontStyle="Normal" FontStretch="Normal" />
</StackPanel>
</Grid>
<!-- a grid -->
<Grid Grid.Row="1">
<ScrollViewer VerticalScrollBarVisibility="Auto" CanContentScroll="True" >
<StackPanel Name="spAgents" />
</ScrollViewer>
</Grid>
</Grid>
</Grid>
</Border>
</Grid>
Thanks
I changed it to a DockPanel and it still sizes up when adding text ( see above )
Here is another project where it does NOT grow with additional text added:
<Border Grid.Column="0" Margin="5,5,0,5">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<DockPanel Grid.Row="0" >
<RichTextBox Name="txtMessageHistory" Margin="5" Background="#FF343434" Foreground="#FFDEDEDE" VerticalScrollBarVisibility="Visible">
<RichTextBox.Resources>
<Style TargetType="{x:Type Paragraph}">
<Setter Property="Margin" Value="0"/>
</Style>
</RichTextBox.Resources>
</RichTextBox>
</DockPanel>
<StackPanel Grid.Row="1" Orientation="Vertical">
<TextBox x:Name="ChatTextBox" Background="#FFDEDEDE" Foreground="Black" Margin="5,5,5,5" />
<StackPanel Orientation="Horizontal">
<Button x:Name="SendMsg" Content="Send msg " Click="btnSendMessage_Click" Margin="0,0,5,0"/>
<Button x:Name="ClearMessages" Content="Clear messages" Click="ClearMessages_Click" Margin="0,0,5,0"/>
<Button x:Name="SendMsg_Ping" Content="Send Ping" Click="SendMsg_Ping_Click" Margin="0,0,5,0" />
<Button x:Name="SendMsg_E2PRequest" Content="Send E2P Request" Click="SendMsg_E2PRequest_Click" Margin="0,0,5,0"/>
<Button x:Name="SendMsg_MARequest" Content="Send Mon App Request" Click="SendMsg_MARequest_Click" Margin="0,0,5,0"/>
<Button x:Name="SendMsg_PluginStatusRequest" Content="Send Plugin stat Request" Click="SendMsg_PluginStatusRequest_Click" Margin="0,0,5,0"/>
</StackPanel>
</StackPanel>
</Grid>
</Border>
Another try:
Removed Grid and Dockpanel - still grows in size:
<Border Grid.Column="1" BorderThickness="1" Padding="5" BorderBrush="#FF878383" CornerRadius="10">
<Grid>
<RichTextBox Name="ManagerNotice" Background="#FF343434" Foreground="#FFDEDEDE" >
<RichTextBox.Resources>
<Style TargetType="{x:Type Paragraph}">
<Setter Property="Margin" Value="0"/>
</Style>
</RichTextBox.Resources>
</RichTextBox>
</Grid>
</Border>
Attempt (last and this is working)
When I explicitly set the height to some number, it behaves
<DockPanel Grid.Row="1" >
<RichTextBox Height="100" Name="ManagerNotice" Margin="5" Background="#FF343434" Foreground="#FFDEDEDE" VerticalScrollBarVisibility="Visible">
<RichTextBox.Resources>
<Style TargetType="{x:Type Paragraph}">
<Setter Property="Margin" Value="0"/>
</Style>
</RichTextBox.Resources>
</RichTextBox>
</DockPanel>
Here is the answer, after multiple comments and great feedback:
<DockPanel Grid.Row="1" >
<RichTextBox Height="100" Name="ManagerNotice" Margin="5" Background="#FF343434" Foreground="#FFDEDEDE" VerticalScrollBarVisibility="Visible">
<RichTextBox.Resources>
<Style TargetType="{x:Type Paragraph}">
<Setter Property="Margin" Value="0"/>
</Style>
</RichTextBox.Resources>
</RichTextBox>
</DockPanel>

WinRT - Thumbnail instead of Bing Map control

In a windows store project i have a page that creates several big squares, with this format
<DataTemplate x:Key="MyMeetingsWithMapSquares">
<Grid Width="350" Height="290" DataContext="{Binding}" >
<StackPanel >
<StackPanel.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0,1" >
<GradientStop Color="#FF0072C6" Offset="0"/>
<GradientStop Color="#FF008FD4" Offset="1"/>
</LinearGradientBrush>
</StackPanel.Background>
<Grid DataContext="{Binding}">
<Grid.RowDefinitions>
<RowDefinition Height="90"/>
<RowDefinition Height="60"/>
<RowDefinition Height="50"/>
<RowDefinition Height="150"/>
</Grid.RowDefinitions>
<Border BorderBrush="#0166a0" BorderThickness="0,0,0,1" Margin="10,0,10,0">
<StackPanel Grid.Row="0">
<Grid DataContext="{Binding}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="220"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal">
<TextBlock Grid.Row="0" Margin="0,16,0,0" Text="{Binding MyMeetingSquareDayNumber}" Width="40" FontFamily="Segoe UI Semibold" FontSize="33" FontWeight="SemiBold" VerticalAlignment="Top"/>
<TextBlock Grid.Row="0" Margin="0,16,0,0" Text="{Binding MyMeetingSquareMonthText}" Width="60" FontFamily="Segoe UI Regular" FontSize="33" FontWeight="Normal" VerticalAlignment="Top"/>
<TextBlock Grid.Row="0" Margin="0,16,0,0" Text="{Binding MyMeetingSquareYearText}" Width="60" FontFamily="Segoe UI Light" FontSize="33" FontWeight="Light" VerticalAlignment="Top" HorizontalAlignment="Left"/>
</StackPanel>
<TextBlock Grid.Row="1" Margin="0,5,0,0" Text="Business meeting" FontFamily="Segoe UI Semibold" FontSize="24" FontWeight="SemiBold" VerticalAlignment="Center"/>
</Grid>
<StackPanel Grid.Column="1" VerticalAlignment="Center">
<TextBlock Text="{Binding MyMeetingSquareDayHour}" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,10,0"/>
</StackPanel>
</Grid>
</StackPanel>
</Border>
<Border Grid.Row="1" BorderBrush="#0166a0" BorderThickness="0,0,0,1" Margin="10,0,10,0">
<StackPanel >
<TextBlock Text="{Binding MyMeetingSquareSummary}" FontFamily="Segoe UI Light" FontSize="16" Margin="0,10,0,10" TextWrapping="Wrap"/>
</StackPanel>
</Border>
<StackPanel Grid.Row="2">
<Border BorderBrush="#0166a0" BorderThickness="0,0,0,1" Margin="10,0,10,0">
<ScrollViewer VerticalScrollBarVisibility="Hidden" VerticalScrollMode="Disabled" HorizontalScrollBarVisibility="Hidden" HorizontalScrollMode="Enabled">
<GridView ItemContainerStyle="{StaticResource GridViewItemStyle2}" ItemsSource="{Binding MyMeetingsSquareUsers}" ItemTemplateSelector="{StaticResource meetingSelector}" Grid.Row="1" Margin="0,10,0,0" SelectionMode="None" HorizontalContentAlignment="Left" VerticalContentAlignment="Bottom">
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<ItemsWrapGrid Orientation="Vertical" MaximumRowsOrColumns="1"/>
</ItemsPanelTemplate>
</GridView.ItemsPanel>
</GridView>
</ScrollViewer>
</Border>
</StackPanel>
<StackPanel Grid.Row="3" Height="150" DataContext="{Binding}" Background="Red">
<Grid Tapped="Map_DoubleTappedOverride">
<StackPanel Height="55" Width="190" Canvas.ZIndex="11" Margin="10,0,0,60" VerticalAlignment="Center" HorizontalAlignment="Center" Orientation="Vertical">
<StackPanel.Background>
<ImageBrush Stretch="Uniform" ImageSource="ms-appx:///Images/Meetings/meetingAddress.png"/>
</StackPanel.Background>
<ScrollViewer HorizontalScrollBarVisibility="Disabled" HorizontalScrollMode="Disabled" VerticalScrollBarVisibility="Hidden" Width="175" Margin="5,0,0,0" Height="50" VerticalAlignment="Center" HorizontalAlignment="Center" >
<TextBlock Text="{Binding Address}" Margin="10,0,0,0" FontFamily="Segoe UI Semilight" FontSize="14" Foreground="Black" Width="170" TextWrapping="WrapWholeWords" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</ScrollViewer>
</StackPanel>
<Maps:Map x:Name="miniMap" Tag="{Binding MyMeetingSquareLat}" Loaded="Map_Loaded" DataContext="{Binding}" ZoomLevel="15" Margin="0,10,0,0" ShowBreadcrumb="False" Height="150" ShowNavigationBar="False" ShowScaleBar="False" ShowTraffic="True" ShowBuildings="True" Width="350" Credentials="AnZKLHgAfKSwa5BAB2Kr-g8KENJBm1US3tVieyOxxxxxxxJZVXyUgRIwM" >
<Maps:Map.Children>
<Maps:Pushpin Foreground="{x:Null}">
<Maps:Pushpin.RenderTransform>
<CompositeTransform />
</Maps:Pushpin.RenderTransform>
<Maps:Pushpin.Background>
<ImageBrush Stretch="Fill" ImageSource="ms-appx:///Images/Meetings/meetingsPushpin.png"/>
</Maps:Pushpin.Background>
<Maps:MapLayer.Position>
<Maps:Location Latitude="{Binding MyMeetingSquareLat}" Longitude="{Binding MyMeetingSquareLng}" />
</Maps:MapLayer.Position>
</Maps:Pushpin>
</Maps:Map.Children>
</Maps:Map>
</Grid>
</StackPanel>
</Grid>
</StackPanel>
</Grid>
</DataTemplate>
My problem was that i was having performance issues, mainly some high memory usage. If i removed the Map part from my template the memory usage would drop to 1/4.
My question is if Bing maps has some sort of thumb preview or how can i replace my map with a image of the pushpin location on the map. Having a bunch of map controls on same page seems to affect performance.
Yes, its called the Bing Maps REST Static Imagery Service: https://msdn.microsoft.com/en-us/library/ff701724.aspx

Winrt - Binding values to Latitude and Longitude on Bing Map

I have this DataTemplate that contains a Map
<DataTemplate x:Key="MyMeetingsWithMapSquares">
<Grid Width="350" Height="290" DataContext="{Binding}" >
<StackPanel >
<StackPanel.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0,1" >
<GradientStop Color="#FF0072C6" Offset="0"/>
<GradientStop Color="#FF008FD4" Offset="1"/>
</LinearGradientBrush>
</StackPanel.Background>
<Grid DataContext="{Binding}">
<Grid.RowDefinitions>
<RowDefinition Height="90"/>
<RowDefinition Height="60"/>
<RowDefinition Height="50"/>
<RowDefinition Height="150"/>
</Grid.RowDefinitions>
<Border BorderBrush="#0166a0" BorderThickness="0,0,0,1" Margin="10,0,10,0">
<StackPanel Grid.Row="0">
<Grid DataContext="{Binding}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="220"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal">
<TextBlock Grid.Row="0" Margin="0,16,0,0" Text="{Binding MyMeetingSquareDayNumber}" Width="40" FontFamily="Segoe UI Semibold" FontSize="33" FontWeight="SemiBold" VerticalAlignment="Top"/>
<TextBlock Grid.Row="0" Margin="0,16,0,0" Text="{Binding MyMeetingSquareMonthText}" Width="60" FontFamily="Segoe UI Regular" FontSize="33" FontWeight="Normal" VerticalAlignment="Top"/>
<TextBlock Grid.Row="0" Margin="0,16,0,0" Text="{Binding MyMeetingSquareYearText}" Width="60" FontFamily="Segoe UI Light" FontSize="33" FontWeight="Light" VerticalAlignment="Top" HorizontalAlignment="Left"/>
</StackPanel>
<TextBlock Grid.Row="1" Margin="0,5,0,0" Text="Business meeting" FontFamily="Segoe UI Semibold" FontSize="24" FontWeight="SemiBold" VerticalAlignment="Center"/>
</Grid>
<StackPanel Grid.Column="1" VerticalAlignment="Center">
<TextBlock Text="{Binding MyMeetingSquareDayHour}" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,10,0"/>
</StackPanel>
</Grid>
</StackPanel>
</Border>
<Border Grid.Row="1" BorderBrush="#0166a0" BorderThickness="0,0,0,1" Margin="10,0,10,0">
<StackPanel >
<TextBlock Text="{Binding MyMeetingSquareSummary}" FontFamily="Segoe UI Light" FontSize="16" Margin="0,10,0,10" TextWrapping="Wrap"/>
</StackPanel>
</Border>
<StackPanel Grid.Row="2">
<Border BorderBrush="#0166a0" BorderThickness="0,0,0,1" Margin="10,0,10,0">
<ScrollViewer VerticalScrollBarVisibility="Hidden" VerticalScrollMode="Disabled" HorizontalScrollBarVisibility="Hidden" HorizontalScrollMode="Enabled">
<GridView ItemContainerStyle="{StaticResource GridViewItemStyle2}" ItemsSource="{Binding MyMeetingsSquareUsers}" ItemTemplateSelector="{StaticResource meetingSelector}" Grid.Row="1" Margin="0,10,0,0" SelectionMode="None" HorizontalContentAlignment="Left" VerticalContentAlignment="Bottom">
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<ItemsWrapGrid Orientation="Vertical" MaximumRowsOrColumns="1"/>
</ItemsPanelTemplate>
</GridView.ItemsPanel>
</GridView>
</ScrollViewer>
</Border>
</StackPanel>
<StackPanel Grid.Row="3" Height="150" DataContext="{Binding}">
<Maps:Map Tag="{Binding MyMeetingSquareLat}" Margin="0,10,0,0" DoubleTappedOverride="Map_DoubleTappedOverride" ShowBreadcrumb="False" Height="150" ShowNavigationBar="False" ShowScaleBar="False" ShowTraffic="False" Width="350" Credentials="AnZKLHgAfKSwa5BAB2Kr-g8KENJBm1US3txxxxxxzCDUAgxhgJZVXyUgRIwM" ViewChanged="Map_ViewChanged" >
<Maps:Map.Center>
<Maps:Location Latitude="{Binding MyMeetingSquareLat}" Longitude="{Binding MyMeetingSquareLng}"/>
</Maps:Map.Center>
</Maps:Map>
</StackPanel>
</Grid>
</StackPanel>
</Grid>
</DataTemplate>
Im trying to bind values to its latitude and longitude, but for some reason they are allways 0. i tried binding one of the values to the Map tag and it worked, the tag was 49.597378 but the latitude was 0.
how do i pass the values to the map lat and lng ?
EDIT
so i've changed some things on my code and added a pushpin
<StackPanel Grid.Row="3" Height="150" DataContext="{Binding}">
<Maps:Map Tag="{Binding MyMeetingSquareLat}" DataContext="{Binding}" ZoomLevel="5" Margin="0,10,0,0" DoubleTappedOverride="Map_DoubleTappedOverride" ShowBreadcrumb="False" Height="150" ShowNavigationBar="False" ShowScaleBar="False" ShowTraffic="False" Width="350" Credentials="AnZKLHgAfKSwa5BAB2Kr-g8KENJBmxxxxxxyOCEwbJzCDUAgxhgJZVXyUgRIwM" ViewChanged="Map_ViewChanged" >
<Maps:Map.Center>
<Maps:Location Latitude="{Binding MyMeetingSquareLat}" Longitude="{Binding MyMeetingSquareLng}"/>
</Maps:Map.Center>
<Maps:Map.Children>
<Maps:Pushpin >
<Maps:Pushpin.Background>
<ImageBrush Stretch="Fill" ImageSource="ms-appx:///Assets/Pdf/edit.png"/>
</Maps:Pushpin.Background>
<Maps:MapLayer.Position>
<Maps:Location Latitude="{Binding MyMeetingSquareLat}" Longitude="{Binding MyMeetingSquareLng}" />
</Maps:MapLayer.Position>
</Maps:Pushpin>
</Maps:Map.Children>
</Maps:Map>
</StackPanel>
</Grid>
</StackPanel>
The pushpins appear in the correct position, but the map center continues to go to point 0 0 , it doesnt read the binded values for some reason.
You are binding a string (as you said in the comments) to the Latitude property of Maps:Location. However Maps:Location expects a double for this value.
You need to convert this value into a double with the following code:
Double.Parse(myStringValue);
If the value MyMeetingSquareLat can't be changed to a string itself, then add another property like this, and bind to it instead:
public Double MyMeetingSquareLatDouble
{
get
{
return Double.Parse(this.MyMeetingSquareLat);
}
}

Absolute position element WPF

I want to position a cross button in the top right of my dialog without it affecting the flow of the rest of the dialog, this seems to be rather difficult when commpared to CSS?
This currently aligned the content about 20px from the right hand side because its still in column 0 and column 1 is occupying that space. Ideally all the content would be within a StackPanel with the close button being positioned top right. Failing that I guess it may be possible to make the content span the two columns? How do I fix this?
Here is my current XAML:
<Grid Margin="10">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0">
<TextBlock x:Name="UI_DialogTitle" Style="{StaticResource i2_TitleTextBlock}" Text="{TemplateBinding DialogTitle}" Visibility="{TemplateBinding DialogTitleVisibility}" Margin="0,0,0,10"/>
<ContentPresenter x:Name="TheContentPresenter"/>
</StackPanel>
<Button x:Name="UI_CloseDialog" Style="{StaticResource i2_CloseDialogButton}" Visibility="{TemplateBinding CloseButtonVisibility}" Grid.Column="1" Grid.Row="0"/>
</Grid>
Turns out I needed the ColumnSpan property - this all works now!
<Grid Margin="10">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Grid.ColumnSpan="2">
<TextBlock x:Name="UI_DialogTitle" Style="{StaticResource i2_TitleTextBlock}" Text="{TemplateBinding DialogTitle}" Visibility="{TemplateBinding DialogTitleVisibility}" Margin="0,0,0,10"/>
<ContentPresenter x:Name="TheContentPresenter"/>
</StackPanel>
<Button x:Name="UI_CloseDialog" Style="{StaticResource i2_CloseDialogButton}" Visibility="{TemplateBinding CloseButtonVisibility}" Grid.Column="1" Grid.Row="0"/>
</Grid>
I have done something similar. Check the btnClose and the screenshot.
<Grid x:Name="LayoutRoot" Margin="2">
<Border x:Name="PopupBorder" BorderBrush="SlateGray" BorderThickness="1.5" CornerRadius="12" Visibility="Visible" Opacity="20" Margin="0,0,0,0">
<Border.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF000000"/>
<GradientStop Color="#CC4895DE" Offset="0.844"/>
<GradientStop Color="#FF346592" Offset="0.393"/>
<GradientStop Color="#FFFFFFFF" Offset="1"/>
</LinearGradientBrush>
</Border.Background>
<TextBox Height="26" Style="{StaticResource TextBoxStyle}" Margin="0,0,30,220" Name="txtQuotationNumber" Width="332" />
</Border>
**<Button Margin="0,4,4,0" Click="OKButton_Click" Cursor="Hand" x:Name="btnClose" Style="{StaticResource CloseStyleX}" VerticalAlignment="Top" ToolTipService.ToolTip="Close Popup"/>**
-- Datagrid here
-- COMBOBOX HERE
<TextBox Height="26" Name="txtValue" IsTabStop="True" VerticalAlignment="Top" Margin="178,10,500,0"></TextBox>
<Button Content="Search" Click="btnSearch_Click" Style="{StaticResource ButtonStyle}" Height="26" HorizontalAlignment="Right" Margin="0,10,37,0" Name="btnSearch" VerticalAlignment="Top" Width="104" />
</Grid>

AG_E_PARSER_BAD_PROPERTY_VALUE (Line 7;Position 51)

This is my XAML code in my project, in this first i display MainListBox then display ChatListBox depending on user selection. When user select to chat then i got run time Xaml parseing exception.
this is my whole Xaml code...
<phone:PhoneApplicationPage
x:Class="DocomoMessenger.View.Buddies"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"
shell:SystemTray.IsVisible="True" Loaded="PhoneApplicationPage_Loaded">
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="126"/>
<RowDefinition Height="580*"/>
<RowDefinition Height="75"/>
</Grid.RowDefinitions>
<!--TitlePanel contains the name of the application and page title-->
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="2,2,0,2">
<ProgressBar Height="3" Name="waitprogess" Margin="0,2,0,0" />
<TextBlock x:Name="txtload" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,5,12,0" />
<TextBlock x:Name="PageTitle" Text="page name" Margin="1,0,0,0" Style="{StaticResource PhoneTextTitle1Style}" HorizontalAlignment="Center" />
</StackPanel>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="2,0,2,0">
<Border BorderThickness="5" BorderBrush="DarkGray" CornerRadius="10" Name="buddyborder">
<ListBox x:Name="MainListBox" >
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Height="100" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="50"/>
</Grid.ColumnDefinitions>
<Image Grid.Column="0" Source="{Binding IM}" Stretch="Fill" Width="50" Height="50" VerticalAlignment="Center" HorizontalAlignment="Center" ></Image>
<StackPanel Margin="1,4,0,0" Grid.Column="1" x:Name="details" Height="100">
<TextBlock Text="{Binding Name}" Style="{StaticResource PhoneTextNormalStyle}" Foreground="Brown" Padding="10"/>
<TextBlock Text="{Binding StatusMsg}" FontSize="{StaticResource PhoneFontSizeSmall}" TextWrapping="Wrap" Padding="10" />
</StackPanel>
<Image Tag="{Binding Name}" Source="{Binding IMChat}" Grid.Column="2" Stretch="Uniform" Width="40" Height="40" VerticalAlignment="Center" HorizontalAlignment="Center" Name="imgchat" MouseLeftButtonUp="imgchat_MouseLeftButtonUp"></Image>
<Line Stretch="UniformToFill" Grid.ColumnSpan="3" Stroke="DarkGray" StrokeThickness="2" Margin="0,10,0,0" X1="10" Y1="10" Y2="10" VerticalAlignment="Bottom" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Border>
<ListBox x:Name="ChatListBox" Margin="2,2,0,0" Opacity="1" Visibility="Collapsed" >
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Name="megrid" Margin="3,5,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="40*"/>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{Binding FirstCol}"/>
<ColumnDefinition Width="20"/>
<ColumnDefinition Width="{Binding LastCol}"/>
</Grid.ColumnDefinitions>
<Image Name="imgbud" Source="{Binding IM}" Grid.Column="{Binding ImgCol}" Grid.Row="1" Stretch="Uniform" Width="50" Height="50"/>
<Rectangle Grid.RowSpan="2" RadiusY="20" RadiusX="20" Grid.Column="{Binding RectCol}" Fill="{Binding Bru}" />
<TextBlock Text="{Binding Name}" Grid.Row="0" TextWrapping="Wrap" Grid.Column="{Binding RectCol}" Padding="10" />
<TextBlock Text="{Binding Time}" Grid.Row="1" Grid.Column="{Binding RectCol}" Padding="10" />
<Path Data="{Binding Obj}" Fill="{Binding Bru}" Margin="0,0,-5,0" HorizontalAlignment="{Binding HorAlig}" Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
<Grid x:Name="sendmsg" Height="75" VerticalAlignment="Bottom" Grid.Row="2" Visibility="Collapsed">
<TextBox Name="txtmsg" Text="type" Padding="5" Opacity="0.8" MouseLeftButtonUp="txtmsg_MouseLeftButtonUp" Width="370" HorizontalAlignment="Left" />
<Image Name="imgsend" Width="100" Height="46" Source="/DocomoMessenger;component/Themes/send.png" HorizontalAlignment="Right" Stretch="UniformToFill" Margin="0,12,4,17" MouseLeftButtonUp="imgsend_MouseLeftButtonUp"/>
</Grid>
</Grid>
<!--Sample code showing usage of ApplicationBar-->
<!--<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
<shell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="Button 1"/>
<shell:ApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="Button 2"/>
<shell:ApplicationBar.MenuItems>
<shell:ApplicationBarMenuItem Text="MenuItem 1"/>
<shell:ApplicationBarMenuItem Text="MenuItem 2"/>
</shell:ApplicationBar.MenuItems>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>-->
when I run this code i got following XamlParsinException error.
Anyone help me.
Thanks in Advance
Pavan.
I can't pin it down, it is a nearly generic message that doesn't say much.
Here is what I would do:
Comment out all content so you are left with <PhoneApplicationPage ...>
Comment out all C# code that depends on the XAML you just commented out
Make sure the application compiles.
Now slowly, step by step, add xaml elements back in. Until you find the offending line.
If 4. is too hard you could reverse this trick; comment out part by part.
whats in your PhoneApplicationPage_Loaded method?
apart from a missing end tag
</phone:PhoneApplicationPage>
in your snippet above I was able to build and run this in WP7 7.1. I did have to omit your Loaded and MouseLeftButtonUp refers though as I don't have your full code.

Categories