How would I make mainGrid horizontally stretch to the size of the listbox? I've got the listbox set to stretch and auto width and mainGrid set to stretch and auto but its not stretching to the size of the listbox.
<DataTemplate x:Key="AccountItem">
<Grid Name="mainGrid" ShowGridLines="True">
<Grid.Background>
<LinearGradientBrush EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.5,0">
<GradientStop Color="#FFFFFFF3"/>
<GradientStop Color="DarkGray" Offset="0.672"/>
</LinearGradientBrush>
</Grid.Background>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid VerticalAlignment="Top" Grid.Row="0" >
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock x:Name="accountName" TextWrapping="Wrap" Text="{Binding Name}" HorizontalAlignment="Left" Foreground="White"/>
<TextBlock x:Name="accountType" TextWrapping="Wrap" Text="{Binding Type}" Foreground="White" HorizontalAlignment="Right" Grid.Column="1"/>
</Grid>
<Grid VerticalAlignment="Center" Grid.Row="1" >
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock TextWrapping="Wrap" Text="Balance:" HorizontalAlignment="Left" Foreground="White"/>
<TextBlock x:Name="accountBalance" TextWrapping="Wrap" Text="{Binding Balance}" HorizontalAlignment="Right" Foreground="White" Grid.Column="1"/>
</Grid>
<Grid VerticalAlignment="Bottom" Grid.Row="2" >
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock TextWrapping="Wrap" Text="Available Balance:" HorizontalAlignment="Left" Foreground="White"/>
<TextBlock x:Name="accountAvailableBalance" TextWrapping="Wrap" Text="{Binding AvailableBalance}" HorizontalAlignment="Right" Foreground="White" Grid.Column="1"/>
</Grid>
</Grid>
</DataTemplate>
<Grid x:Name="LayoutRoot">
<Grid.Background>
<ImageBrush Stretch="Fill" ImageSource="/Assets/background.png"/>
</Grid.Background>
<ListBox x:Name="accountsList" Margin="20,136,20,0" ItemTemplate="{StaticResource AccountItem}" />
</Grid>
Try to set HorizontalContentAlignment to Strecth:
<ListBox x:Name="accountsList" Margin="20,136,20,0" ItemTemplate="{StaticResource AccountItem}">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
Related
I'm trying to stretch the orange grid so that it fills out horizontally, currently it only fills out the length of the textblock that's inside. Why is that?
<ListView ItemsSource="{Binding Users}"
Grid.Column="0">
<ListView.ItemTemplate>
<DataTemplate>
<Grid Height="50"
Background="Orange"
HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Rectangle RadiusX="20" RadiusY="20"
Width="30" Height="30">
<Rectangle.Fill>
<SolidColorBrush Color="Orange" />
</Rectangle.Fill>
</Rectangle>
<StackPanel Grid.Column="1"
VerticalAlignment="Center"
HorizontalAlignment="Stretch">
<TextBlock Text="{Binding }"
FontWeight="Bold"
HorizontalAlignment="Stretch"/>
</StackPanel>
<Grid.Effect>
<DropShadowEffect Opacity=".1"
BlurRadius="10"
Direction="280"/>
</Grid.Effect>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
This is what it looks like
I forgot to add HorizontalContentAlignment="Stretch" to the ListView.
<ListView ItemsSource="{Binding Users}"
Grid.Column="1"
HorizontalContentAlignment="Stretch">
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);
}
}
I have the following Question:
I have a Layout with a Grid and ListViews.
These ListViews will always contain 5 Items.
Now these Items should fill the complete Height of the ListView.
So I thought I get the Height of the ListView an then devide it by 5 and set the Height of each Row to the Result.
But the ListView.Height Property returns strange Values.
I listen to the Window SizeChanged Event.
I hope somebody can tell me how to do it, or if there is a better alternative.
<Window x:Class="KalenderDesingTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Kalender" Height="600" Width="800" SizeChanged="Window_SizeChanged">
<Grid>
<Grid.Resources>
<Style TargetType="{x:Type ListViewItem}">
<Style.Setters>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListViewItem}">
<Border BorderBrush="#5076A7" BorderThickness="1" CornerRadius="4">
<Border.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="#FFFFFF" Offset="0.0"/>
<GradientStop Color="#C0D3EA" Offset="1.0"/>
</LinearGradientBrush>
</Border.Background>
<StackPanel TextElement.FontFamily="Segoe UI"
TextElement.FontSize="12">
<TextBlock FontWeight="Bold" Padding="3,0,0,0" Text="{Binding Path=Name}"/>
<TextBlock Padding="3,0,0,0" Text="{Binding Path=Age}"/>
</StackPanel>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style.Setters>
</Style>
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Button Grid.Column="0" Grid.Row="0"
Grid.RowSpan="3" x:Name="NeuerTermin">Neuer Termin</Button>
<Button Grid.Column="2" Grid.Row="0" x:Name="Back">Zurück</Button>
<ComboBox Grid.Column="3" Grid.Row="0" x:Name="Month"></ComboBox>
<Button Grid.Column="4" Grid.Row="0" x:Name="Forward">Vor</Button>
<TextBlock Grid.Column="1" Grid.Row="1" Text="Montag" HorizontalAlignment="Center"/>
<TextBlock Grid.Column="2" Grid.Row="1" Text="Dienstag" HorizontalAlignment="Center"/>
<TextBlock Grid.Column="3" Grid.Row="1" Text="Mittwoch" HorizontalAlignment="Center"/>
<TextBlock Grid.Column="4" Grid.Row="1" Text="Donnerstag" HorizontalAlignment="Center"/>
<TextBlock Grid.Column="5" Grid.Row="1" Text="Freitag" HorizontalAlignment="Center"/>
<StackPanel Orientation="Horizontal" Grid.Column="1"
Grid.Row="2" VerticalAlignment="Stretch">
<CheckBox x:Name="MoV" VerticalAlignment="Center" Margin="0,0,5,0">V</CheckBox>
<CheckBox x:Name="MoN" VerticalAlignment="Center" Margin="0,0,5,0">N</CheckBox>
<CheckBox x:Name="MoT" VerticalAlignment="Center">T</CheckBox>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Column="2"
Grid.Row="2" VerticalAlignment="Stretch">
<CheckBox x:Name="DiV" VerticalAlignment="Center" Margin="0,0,5,0">V</CheckBox>
<CheckBox x:Name="DiN" VerticalAlignment="Center" Margin="0,0,5,0">N</CheckBox>
<CheckBox x:Name="DiT" VerticalAlignment="Center">T</CheckBox>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Column="3"
Grid.Row="2" VerticalAlignment="Stretch">
<CheckBox x:Name="MiV" VerticalAlignment="Center" Margin="0,0,5,0">V</CheckBox>
<CheckBox x:Name="MiN" VerticalAlignment="Center" Margin="0,0,5,0">N</CheckBox>
<CheckBox x:Name="MiT" VerticalAlignment="Center">T</CheckBox>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Column="4"
Grid.Row="2" VerticalAlignment="Stretch">
<CheckBox x:Name="DoV" VerticalAlignment="Center" Margin="0,0,5,0">V</CheckBox>
<CheckBox x:Name="DoN" VerticalAlignment="Center" Margin="0,0,5,0">N</CheckBox>
<CheckBox x:Name="DoT" VerticalAlignment="Center">T</CheckBox>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Column="5"
Grid.Row="2" VerticalAlignment="Stretch">
<CheckBox x:Name="FrV" VerticalAlignment="Center" Margin="0,0,5,0">V</CheckBox>
<CheckBox x:Name="FrN" VerticalAlignment="Center" Margin="0,0,5,0">N</CheckBox>
<CheckBox x:Name="FrT" VerticalAlignment="Center">T</CheckBox>
</StackPanel>
<ListView Grid.Column="1" Grid.Row="3" x:Name="lvMoV"></ListView>
<ListView Grid.Column="1" Grid.Row="4" x:Name="lvMoN"></ListView>
<ListView Grid.Column="2" Grid.Row="3" x:Name="lvDiV"></ListView>
<ListView Grid.Column="2" Grid.Row="4" x:Name="lvDiN"></ListView>
<ListView Grid.Column="3" Grid.Row="3" x:Name="lvMiV"></ListView>
<ListView Grid.Column="3" Grid.Row="4" x:Name="lvMiN"></ListView>
<ListView Grid.Column="4" Grid.Row="3" x:Name="lvDoV"></ListView>
<ListView Grid.Column="4" Grid.Row="4" x:Name="lvDoN"></ListView>
<ListView Grid.Column="5" Grid.Row="3" x:Name="lvFrV"></ListView>
<ListView Grid.Column="5" Grid.Row="4" x:Name="lvFrN"></ListView>
</Grid>
</Window>
This is my code behind:
private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
{
int wHeight = (int)lvMoN.Height;
}
I would do like this:
int wHeight = (int)lvMoN.ActualHeight;
I have a GridView that looks as follows:
<Page
x:Name="pageRoot"
x:Class="View.ServiceModule"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:View"
xmlns:common="using:View.Common"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Page.Resources>
<CollectionViewSource
x:Name="groupedItemsViewSource"
Source="{Binding ServiceTasksFiltered}"
IsSourceGrouped="true"
ItemsPath="ServiceTasksFiltered">
</CollectionViewSource>
</Page.Resources>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.ChildrenTransitions>
<TransitionCollection>
<EntranceThemeTransition/>
</TransitionCollection>
</Grid.ChildrenTransitions>
<Grid.RowDefinitions>
<RowDefinition Height="140"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<GridView
Visibility="Collapsed"
x:Name="serviceTasksFilteredGridView"
TabIndex="1"
Grid.RowSpan="2"
Padding="116,136,116,46"
ItemsSource="{Binding ServiceTasksFiltered, Mode=TwoWay}"
SelectionMode="None"
IsSwipeEnabled="false"
IsItemClickEnabled="true"
ScrollViewer.VerticalScrollMode="Auto"
ScrollViewer.VerticalScrollBarVisibility="Auto"
VerticalAlignment="Top">
<GridView.ItemContainerStyle>
<Style TargetType="GridViewItem">
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
</Style>
</GridView.ItemContainerStyle>
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel HorizontalAlignment="Stretch"/>
</ItemsPanelTemplate>
</GridView.ItemsPanel>
<GridView.Header>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"></ColumnDefinition>
<ColumnDefinition Width="200"></ColumnDefinition>
<ColumnDefinition Width="500"></ColumnDefinition>
<ColumnDefinition Width="300"></ColumnDefinition>
<ColumnDefinition Width="300"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Text="Debitornr." TextWrapping="Wrap" FontSize="24" FontWeight="Bold"/>
<TextBlock Grid.Column="1" Text="Name" TextWrapping="Wrap" FontSize="24" FontWeight="Bold"/>
<TextBlock Grid.Column="2" Text="Belegnr." TextWrapping="Wrap" FontSize="24" FontWeight="Bold"/>
<TextBlock Grid.Column="3" Text="Reaktionsdatum" TextWrapping="Wrap" FontSize="24" FontWeight="Bold"/>
<TextBlock Grid.Column="4" Text="Priorität" TextWrapping="Wrap" FontSize="24" FontWeight="Bold"/>
</Grid>
</GridView.Header>
<GridView.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"></ColumnDefinition>
<ColumnDefinition Width="200"></ColumnDefinition>
<ColumnDefinition Width="500"></ColumnDefinition>
<ColumnDefinition Width="300"></ColumnDefinition>
<ColumnDefinition Width="300"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding CustomerNo}" TextWrapping="Wrap" FontSize="20"/>
<TextBlock Grid.Column="1" Text="{Binding CustomerName}" TextWrapping="Wrap" FontSize="20"/>
<TextBlock Grid.Column="2" Text="{Binding DocumentNo}" TextWrapping="Wrap" FontSize="20"/>
<TextBlock Grid.Column="3" Text="{Binding ResponseDateDisplay}" TextWrapping="Wrap" FontSize="20"/>
<TextBlock Grid.Column="4" Text="{Binding PriorityDisplay}" TextWrapping="Wrap" FontSize="20"/>
</Grid>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
<!-- Back button and page title -->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button x:Name="backButton" Margin="39,59,39,0"
Click="BackButton"
Style="{StaticResource NavigationBackButtonNormalStyle}"
VerticalAlignment="Top"
AutomationProperties.Name="Back"
AutomationProperties.AutomationId="BackButton"
AutomationProperties.ItemType="Navigation Button"/>
<TextBlock x:Name="pageTitle" Text="Serviceaufgaben" Style="{StaticResource HeaderTextBlockStyle}" Grid.Column="1"
IsHitTestVisible="false" TextWrapping="NoWrap" VerticalAlignment="Bottom" Margin="0,0,30,40"/>
</Grid>
</Grid>
When I try to scroll down to display the bottom rows, the top rows are being moved higher instead of disappearing. Please see the following picture for a better descirption:
GridView with wrong scrolling settings
As you can see the GridView is scrolled down and the rows are behind the header of the page. I need them to disappear.
Any help would be greatly appreciated.
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>