Reputation: 75
I have providing a windows style for all of my windows: Here is what I adding on app.xaml
<Style x:Key="Style.Window.Default" TargetType="Window">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Window">
<Grid Background="{TemplateBinding Background}">
<Grid Name="gridBar" Height="40" VerticalAlignment="Top" Margin="1,0,1,0">
<Grid.Background>
<LinearGradientBrush StartPoint="0, 0" EndPoint="0, 1" Opacity=".1">
<GradientStop Offset="0" Color="{DynamicResource AccentColor}" />
<GradientStop Offset=".3" Color="{DynamicResource AccentColor}" />
<GradientStop Offset="1" Color="Transparent" />
</LinearGradientBrush>
</Grid.Background>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<!-- title -->
<ItemsControl Background="Transparent" MouseDoubleClick="MaximizeClick" >
<TextBlock Text="{TemplateBinding Title}" Margin="8,8,8,0" x:Name="txtTitle"
Style="{StaticResource ModernWindowTitle}"
/>
</ItemsControl>
</Grid>
<Grid VerticalAlignment="top" Margin="0,40,0,0" Background="White">
</Grid>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
And here is what I have on each window:
<Window x:Class="WpfApplication1.MainWindow1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="300" Width="300" Title="title"
Style="{StaticResource Style.Window.Default}" >
<Grid>
<TextBlock Text="text of window 1"></TextBlock>
</Grid>
</Window>
How could I change my code for having or showing data of Grid, because it's not showing data of the Grid
Upvotes: 1
Views: 18
Reputation: 37066
Use a content presenter to insert the content in the ControlTemplate. You never say where you want the content to appear, but this top-aligned grid is empty so maybe that's where?
<Grid VerticalAlignment="top" Margin="0,40,0,0" Background="White">
<ContentPresenter
/>
</Grid>
I have a question for you: What is the purpose of the ItemsControl here?
<!-- title -->
<ItemsControl Background="Transparent" MouseDoubleClick="MaximizeClick" >
<TextBlock Text="{TemplateBinding Title}" Margin="8,8,8,0" x:Name="txtTitle"
Style="{StaticResource ModernWindowTitle}"
/>
</ItemsControl>
Another question: Why do you define four columns in your grid and never use any of them? What are those columns for?
Upvotes: 1