I am creating a Windows 8.1 app using https://slideview.codeplex.com in the Windows 10 with help of Visual Studio 2015.
I have added grid to the design with 1 row and two column. In the first page there is big image and no text and in other pages there is icon and text. So I am putting if 4* in first column for first page and 2* in first for second page all works good but I wanted to make it dynamic in ContentPresenter and then I can assign it from C#.
Kindly somebody help me.
I tried in different way like I put below code in SlideApplicationFrame.cs
#region FirstColumnWidth (DependencyProperty)
public GridLength FirstColumnWidth
{
get { return (GridLength)GetValue(FirstColumnWidthProperty); }
set { SetValue(FirstColumnWidthProperty, value); }
}
public static readonly DependencyProperty FirstColumnWidthProperty =
DependencyProperty.Register("FirstColumnWidth", typeof(GridLength), typeof(SlideApplicationFrame),
new PropertyMetadata(new GridLength(4, GridUnitType.Star)));
#endregion
#region ContentFirstColumnWidth (Attached DependencyProperty)
public static readonly DependencyProperty ContentFirstColumnWidth =
DependencyProperty.RegisterAttached("ContentFirstColumnWidth", typeof(GridLength), typeof(SlideApplicationFrame), new PropertyMetadata(new GridLength(4, GridUnitType.Star)));
public static void SetContentFirstColumnWidth(DependencyObject o, GridLength value)
{
o.SetValue(ContentFirstColumnWidth, value);
}
public static GridLength GetContentFirstColumnWidth(DependencyObject o)
{
return (GridLength)o.GetValue(ContentFirstColumnWidth);
}
#endregion
Then I use it in my ContentPresenter Like this
<ContentPresenter library:SlideApplicationFrame.ContentFirstColumnWidth="{TemplateBinding FirstColumnWidth}" Grid.Column="1"/>
and at the end in style setter
<ColumnDefinition Width="{Binding library:SlideApplicationFrame.ContentFirstColumnWidth}"/>
Whole Style Setter is as below
<Setter Property="HeaderTemplate">
<Setter.Value>
<DataTemplate>
<Grid x:Name="GridHeader">
<Grid.RowDefinitions>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{Binding library:SlideApplicationFrame.ContentFirstColumnWidth}"/>
<ColumnDefinition Width="5*"/>
</Grid.ColumnDefinitions>
</Grid>
</DataTemplate>
</Setter.Value>
</Setter>
and setting from MainPage.xaml.cs
SlideApplicationFrame RootFrame = Window.Current.Content as SlideApplicationFrame;
RootFrame.FirstColumnWidth = new GridLength(4, GridUnitType.Star);
Please help me I will be highly appreciated