Hey so I have a question that's been driving me mad. Basically I have a xaml element that has a wrap panel and a listbox inside it. The listbox has no problems in resizing but the wrap panel will not resize even when I set the horizontal alignment to stretch.
Has anyone any suggestions on how to fix this as it is really driving me nuts? Thanks very much in advance.
<UserControl x:Class="citeright_word.SearchItemsPanel"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:local="clr-namespace:citeright_word"
xmlns:iconPacks1="http://metro.mahapps.com/winfx/xaml/iconpacks"
mc:Ignorable="d"
d:DesignHeight="562.5" d:DesignWidth="300">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="../Resources/Styles.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label x:Name="label" Content="Search:" Margin="5,0,0,0"
VerticalAlignment="Top" FontSize="16" FontWeight="Bold"/>
<WrapPanel HorizontalAlignment="Stretch" Width="auto"
Margin="5,30,5,506.4">
<Button Click="refreshItems" Background="#FFF7F7F7"
VerticalAlignment="Top">
<iconPacks1:PackIconMaterial Kind="Refresh" MaxHeight="12"
MaxWidth="12"/>
</Button>
<TextBox x:Name="textBox" controls:TextBoxHelper.Watermark="Search
Items" controls:TextBoxHelper.ClearTextButton="True"
VerticalAlignment="Top"
KeyDown="textBox_KeyDown" />
</WrapPanel>
<ListBox x:Name="listBox" Margin="5,63,5,5"
HorizontalContentAlignment="Stretch"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
</ListBox>
</Grid>
</UserControl>
Is this what you're looking for?
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Label
x:Name="label"
Grid.Row="0"
Content="Search:"
Margin="5,0,0,0"
VerticalAlignment="Top"
FontSize="16"
FontWeight="Bold"
/>
<Grid
Margin="5"
Grid.Row="1"
>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Button
Grid.Column="0"
Click="refreshItems"
Background="#FFF7F7F7"
VerticalAlignment="Top"
>
<iconPacks1:PackIconMaterial
Kind="Refresh"
MaxHeight="12"
MaxWidth="12" />
</Button>
<TextBox
Grid.Column="1"
Margin="2,0,0,0"
x:Name="textBox"
VerticalAlignment="Top"
KeyDown="textBox_KeyDown"
controls:TextBoxHelper.Watermark="Search Items"
controls:TextBoxHelper.ClearTextButton="True"
/>
</Grid>
<ListBox
x:Name="listBox"
Grid.Row="2"
Margin="5"
HorizontalContentAlignment="Stretch"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListBoxItem>DSG Global Inc (re)</ListBoxItem>
<ListBoxItem>Law Society of New Brunswick v. Aucoin</ListBoxItem>
</ListBox>
</Grid>
I made some substitutions for testing because I don't have your icons or your textbox behaviors or the stuff that goes in the listbox.
I find it deeply incongenial to do XAML layout with margins. I know the designer positions elements that way, but I only use the designer for a visual check on the XAML I write by hand. I find it vastly easier and more powerful to use Grid rows and columns, stackpanels, wrappanels, and the odd UniformGrid. I don't think it's just me: On stack overflow, I've noticed that margin-driven layout correlates very well with folks who are inexperienced with XAML.
Related
I am absolutely new in UWP and its responsive design, so I need help.
Where's the problem?
e.g. I need 4 responsive buttons on landing page, but in each view it looks quite the same. So the button doesn't change, but looks same on desktop, and same on the phone emulator (or when I change screen resolution). For better description, there are some screens:
Buttons on large 23" screen - looks good, but...
..buttons on small 5" screen (portrait) - buttons are larger then canvas...
So my question is: How to make buttons responsive?
Here is my sourcecode:
<Page
x:Class="STCApp.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:STCApp"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="83*"/>
<RowDefinition Height="998*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Button x:Name="button" Content="Button" HorizontalAlignment="Center" VerticalAlignment="Center" Height="83" Width="480" Background="#33DCFF00"></Button>
<Button x:Name="button_Copy" Content="Button" HorizontalAlignment="Center" VerticalAlignment="Center" Height="83" Width="480" Grid.Column="1" Background="#33FF0000"/>
<Button x:Name="button_Copy1" Content="Button" HorizontalAlignment="Center" VerticalAlignment="Center" Height="83" Width="480" Grid.Column="2" Background="#3300FF0C"/>
<Button x:Name="button_Copy2" Content="Button" HorizontalAlignment="Center" VerticalAlignment="Center" Height="83" Width="480" Grid.Column="3" Background="#330080FF"/>
</Grid>
</Page>
For responsive design, we'd better avoid using fixed width and height. We can remove Width and Height setting in Button and set it's HorizontalAlignment and VerticalAlignment to Stretch like following to make the button responsive.
<Button x:Name="button" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="#33DCFF00" Content="Button" />
In this scenario, each button will occupy a cell in the grid and their width and height will change automatically according to the size of the gird. Following is a complete sample and for more info about the layout design, please see Layout for UWP apps.
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="83*" />
<RowDefinition Height="998*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Button x:Name="button" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="#33DCFF00" Content="Button" />
<Button x:Name="button_Copy" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="#33FF0000" Content="Button" />
<Button x:Name="button_Copy1" Grid.Column="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="#3300FF0C" Content="Button" />
<Button x:Name="button_Copy2" Grid.Column="3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="#330080FF" Content="Button" />
</Grid>
In this case it's better for you to use a RelativePanel which you can handle with Visual States that will change according to the available screen size. This might help
Windows 10 RelativePanel Sample
Why does my UWP (Universal Windows Platform) App force extra space at the top and bottom of my app even though there is nothing there?
Here's what it looks like:
Even though in Visual Studio 2013 (design mode) you can see that the blue bounding box displays the bottom of the page as follows:
The outer grey is the device it would be running on.
The XAML looks like the following:
<Page
x:Class="CYaPass.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:CYaPass"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Height="515" Width="570" Background="LightGray" Loaded="Page_Loaded">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="320"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Grid.Row="0">
<TextBlock FontSize="16" HorizontalAlignment="Center">1. Select a Site/Key</TextBlock>
<ListView BorderThickness="2" BorderBrush="Aquamarine"
x:Name="SiteListBox" HorizontalAlignment="Stretch" VerticalAlignment="Center" Height="251"
Margin="10,10,0,0" Width="Auto" SelectionChanged="SiteListBox_SelectionChanged">
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="Padding" Value="5,0,0,0" />
</Style>
</ListView.ItemContainerStyle>
<ListViewItem Content="Item 2"/>
</ListView>
<StackPanel Margin="10,0,0,0" Orientation="Horizontal" Grid.Column="0">
<Button x:Name="DeleteSiteButton" Content="Delete Site"
HorizontalAlignment="Right" Margin="0,0,0,0" VerticalAlignment="Top" Click="DeleteSiteButton_Click"/>
<Button x:Name="AddSiteButton" Content="Add Site" HorizontalAlignment="Right"
Margin="10,0,0,0" VerticalAlignment="Top" Click="AddSiteButton_Click"/>
</StackPanel>
</StackPanel>
<TextBox x:Name="passwordTextBox" HorizontalAlignment="Left" Margin="7,150,0,0" Grid.Row="1" Grid.ColumnSpan="2"
TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="560"/>
<StackPanel HorizontalAlignment="Left" Height="128" Margin="10,0,0,0" Grid.Column="0" Grid.Row="1"
VerticalAlignment="Top" Width="285">
<Grid Margin="0,0,-11,0">
<Grid.RowDefinitions>
<RowDefinition Height="40" ></RowDefinition>
<RowDefinition Height="40" ></RowDefinition>
<RowDefinition Height="40" ></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="180"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<CheckBox x:Name="addUppercaseCheckbox" Grid.Row="0" Grid.Column="0" Content="Add Uppercase" HorizontalAlignment="Stretch" VerticalAlignment="Center" Width="254" Click="addUppercaseCheckbox_Click" Margin="7,0,3,0"/>
<CheckBox x:Name="addSpecialCharscheckBox" Grid.Row="1" Grid.Column="0" Content="Add Special Chars" HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="7,0,3,0"/>
<TextBox x:Name="specialCharsTextBox" Grid.Column="1" Grid.Row="1" Margin="7,0,3,0" VerticalAlignment="Center" HorizontalAlignment="Stretch" Grid.RowSpan="1" TextWrapping="NoWrap" Text="#"/>
<CheckBox x:Name="setMaxLengthCheckBox" Grid.Row="2" Grid.Column="0" Content="Set Max Length" HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="7,0,3,0"/>
<local:NumericUpDown Grid.Column="1" HorizontalAlignment="Left" Margin="7,0,3,0" Grid.Row="2" VerticalAlignment="Center" Width="64"/>
</Grid>
</StackPanel>
<StackPanel Grid.Column="1" Grid.Row="0">
<TextBlock Grid.Column="1" Grid.Row="0" FontSize="16" HorizontalAlignment="Center">2. Draw a pattern</TextBlock>
<Canvas HorizontalAlignment="Center" x:Name="MainCanvas"
Height="252" Width="252" Margin="7,10,0,0" VerticalAlignment="Top" Background="AliceBlue" Tapped="MainCanvas_Tapped" PointerMoved="MainCanvas_PointerMoved"/>
<Button x:Name="ClearGridButton" Content="Clear"
Margin="50,0,10,0" VerticalAlignment="Center" Click="ClearGridButton_Click" HorizontalAlignment="Right"/>
</StackPanel>
</Grid>
</Page>
You can see the page's width is wider than the height, but when the app runs on a desktop or a simulator device (like 7" pad) the extra space is pushed into the top and the bottom.
UWP Forced Minimum?
Is this due to some minimum size or something that UWP forces on apps?
Cannot Resize Smaller When Running
Even if I grab the form's bottom or top bounding frame when the app is running, I cannot make it any smaller.
The Default Content-Alignment is set to Center because you set the Height and Width of your Page, so your page is placed in the Center and isn't filling the whole Screen.
One Possible Solution is to add to the Page xaml Attributes this Piece of Code:
VerticalAlignment="Top".
To set the HorizontalAlignment to the left add this:
HorizontalAlignment="Left".
One more advise: When you don't Need to Display more than one xaml Page at the Screen leave the Page Height and Width to Default.
I'm trying to add a banner that remains fixed in the window to my page and I'm having a tough time.
This is what I am trying to achieve: I want a banner that floats at the top of the window (for an ad), then I want the rest of the content in a scrollable area. First item should be a textBlock, then a textBox, then a button.
This is the code I've got now and it looks right except for the scrolling. Help would be appreciated.
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App2"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:Universal="using:Microsoft.AdMediator.Universal"
x:Class="App2.MainPage"
mc:Ignorable="d" RequestedTheme="Dark">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<StackPanel Grid.RowSpan="3">
<Universal:AdMediatorControl x:Name="AdMediatorName" Height="90" Id="AdMediator-Id" Margin="10,0"/>
<ScrollViewer x:Name="myScrollViewer" VerticalScrollMode="Enabled">
<StackPanel Grid.RowSpan="2">
<TextBlock x:Name ="outputConsole" FontSize="15" RenderTransformOrigin="0.5,0" TextWrapping="WrapWholeWords" Margin="0,0,10,0" FontFamily="Consolas" IsTextSelectionEnabled="True">
<TextBlock.RenderTransform>
<CompositeTransform/>
</TextBlock.RenderTransform>
<TextBlock.Projection>
<PlaneProjection/>
</TextBlock.Projection>
<Run/>
<LineBreak/>
<Run/>
</TextBlock>
<TextBox x:Name="inputConsole" FontSize="20" KeyUp="inputKeyUp" Margin="0,0,10,0" FontFamily="Consolas" IsTapEnabled="True" IsTextPredictionEnabled="True"/>
<Button x:Name="submitButton" Content="Submit" Click="submitButtonClick"/>
</StackPanel>
</ScrollViewer>
</StackPanel>
</Grid>
</Page>
I figured it out. I just needed to put it directly in the grid. Sorry, still learning XAML.
You just answered your question. You have to do something like this,
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal"><TextBlock x:Name ="outputConsole" FontSize="15" RenderTransformOrigin="0.5,0" TextWrapping="WrapWholeWords" Margin="0,0,10,0" FontFamily="Consolas" IsTextSelectionEnabled="True">
<TextBlock.RenderTransform>
<CompositeTransform/>
</TextBlock.RenderTransform>
<TextBlock.Projection>
<PlaneProjection/>
</TextBlock.Projection>
<Run/>
<LineBreak/>
<Run/>
</TextBlock>
<TextBox x:Name="inputConsole" FontSize="20" KeyUp="inputKeyUp" Margin="0,0,10,0" FontFamily="Consolas" IsTapEnabled="True" IsTextPredictionEnabled="True"/>
<Button x:Name="submitButton" Content="Submit" Click="submitButtonClick"/>
</StackPanel>
<ScrollViewer Grid.Row="1">
</ScrollViewer>
I have pane with two grid and there is a listbox in both grid. I'd like to add Drag & Drop feature to the pane, so the user can drag a list element in the left listbox and drop it in the right listbox. I found many great tutorials and I could add the appropriate code to my pane but when the application is running and I click on the menu item of my pane it does not load. If I delete the drag & drop code everything works fine, so the problem is definitely the Drag & Drop feature.
<telerikDocking:RadPane x:Class="Module_TestModule1.PaneSzD" telerikDocking:RadDocking.SerializationTag="Module_TestModule1.PaneSzD"
xmlns:telerikDocking="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Docking"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="PaneSzD1" Header="PaneSzD" IsHidden="True">
<StackPanel Orientation="Horizontal">
<Grid x:Name="LeftGrid" Width="250">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<toolkit:ListBoxDragDropTarget AllowDrop="True" Grid.Row="0">
<ListBox Name="lbLRecords">
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical" />
</ItemsPanelTemplate>
</ListBox>
</toolkit:ListBoxDragDropTarget>
<StackPanel Grid.Row="1" Height="Auto">
<TextBox Name="tbLRecord" KeyDown="tbLRecord_KeyDown" />
<Button Name="btnLAddRecord" Content="Add Record" Height="30" Click="btnLAddRecord_Click" ></Button>
</StackPanel>
</Grid>
<StackPanel Orientation="Vertical">
<Button Name="btnLMoveRecord" Content="Move Record From Left" Height="30" Click="btnLMoveRecord_Click" Margin="10,5,10,5" />
<Button Name="btnRMoveRecord" Content="Move Record From Right" Height="30" Click="btnRMoveRecord_Click" Margin="10,5,10,5" />
</StackPanel>
<Grid x:Name="RightGrid" Width="250">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<toolkit:ListBoxDragDropTarget AllowDrop="True" Grid.Row="0">
<ListBox Name="lbRRecords">
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical" />
</ItemsPanelTemplate>
</ListBox>
</toolkit:ListBoxDragDropTarget>
<StackPanel Grid.Row="1" Height="Auto">
<TextBox Name="tbRRecord" KeyDown="tbRRecord_KeyDown" />
<Button Name="btnRAddRecord" Content="Add Record" Height="30" Click="btnRAddRecord_Click"></Button>
</StackPanel>
</Grid>
</StackPanel>
</telerikDocking:RadPane>
Thanks for any help!
All the info to do this using the Silverlight Control Toolkit can be found here: http://themechanicalbride.blogspot.com/2009/08/new-with-silverlight-toolkit-drag-and.html
Ive created a simple usercontrol and even though the app runs ok applying the template to
I am defining the Control Template here
App.xaml
<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="ResourcesCountDown.App"
>
<Application.Resources>
<ControlTemplate x:Key="myWindowTemplate">
<Grid x:Name="myGrid" Background="Black" Width="50" Height="50">
<ContentPresenter Name="Content"></ContentPresenter>
</Grid>
</ControlTemplate>
</Application.Resources>
</Application>
My UserControl Test.xaml
<UserControl x:Class="ResourcesCountDown.Test"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="100" Height="100" >
<Grid x:Name="LayoutRoot">
<Button Name="myButton" Template="{StaticResource myWindowTemplate}" Foreground="White" Content="CLICK" ></Button>
</Grid>
</UserControl>
My page where the user control is being used and the page where the AG E UNKOWN_ERROR occurs.
If I remove applying the template from test.xaml and remove the Template="{StaticResource myWindowTemplate}" the error goes away, so I know its something BAD in my template definition?
Mainpage.xaml
<UserControl x:Class="ResourcesCountDown.Mainpage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ResourcesCountDown="clr-namespace:ResourcesCountDown"
xmlns:sliverlightControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
Width="Auto" Height="Auto" Name="mainPage"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">
<Grid x:Name="LayoutRoot" Background="White" ShowGridLines="False" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="10"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="10"/>
<RowDefinition Height="80"/>
<RowDefinition Height="10"/>
<RowDefinition Height="*"/>
<RowDefinition Height="10"/>
</Grid.RowDefinitions>
<Border Grid.Column="1" Grid.Row="1" Height="Auto" VerticalAlignment="Top" CornerRadius="5">
<Border.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFFFAA01"/>
<GradientStop Color="#FFFD6900" Offset="1"/>
</LinearGradientBrush>
</Border.Background>
<Grid x:Name="TopBannerGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="500"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<ResourcesCountDown:LogoControl Width="Auto" Height="Auto" Grid.ColumnSpan="2" Margin="5,0,0,0"/>
<ResourcesCountDown:MenuControl Grid.Column="2" HorizontalAlignment="Right" x:Name="menu" Margin="0,-30,0,0"/>
</Grid>
</Border>
<sliverlightControls:WrapPanel Width="900" Height="600" Grid.Column="1" Grid.Row="3" Orientation="Vertical" HorizontalAlignment="Left" VerticalAlignment="Top" >
<ResourcesCountDown:noteControl Width="200" Height="200" headingText="Whats it about?" Margin="10"
noteText="We have one planet with finite resources. This web site was created to try and express the resource consumption.">
</ResourcesCountDown:noteControl>
<ResourcesCountDown:noteControl Width="200" Height="200" headingText="Latest News" Margin="10"
noteText="This week we have see some many new news in just a short time">
</ResourcesCountDown:noteControl>
<ResourcesCountDown:RSSFeed Width="600" Height="200" Margin="10" headingText="Hot News"/>
<ResourcesCountDown:datagridControl Width="600" Height="100" x:Name="theDataGrid" Margin="10" headingText="Stats" > </ResourcesCountDown:datagridControl>
<ResourcesCountDown:Test></ResourcesCountDown:Test>
</sliverlightControls:WrapPanel>
</Grid>
</UserControl>
I think you need a TargetType="Grid" on your <ControlTemplate>:
<ControlTemplate x:Key="myWindowTemplate TargetType="Grid">
....
Also, Grid isn't a ContentControl so I don't think the ContentPresenter you put in the template will behave the way you expect - it could even be causing the error.
Actually, from the code you've posted, your TargetType should be Button because you're applying the template to button.