GridViewを持つAllPageViewというページがあります。GridViewのデータテンプレートは次のとおりです
<GridView.ItemTemplate>
<DataTemplate>
<Canvas Width="{Binding TemplateWidth}" Height="{Binding TemplateHeight}">
<Canvas.Background>
<ImageBrush ImageSource="{Binding PageBackground}"/>
</Canvas.Background>
<Image Height="{Binding TemplateHeight}" Width="{Binding TemplateWidth}" Source="{Binding Page}" Stretch="Uniform" Opacity="1" CacheMode="BitmapCache" />
<StackPanel x:Name="EditDeleteStackPanel" Width="{Binding TemplateWidth}" Height="{Binding TemplateHeight}" Opacity="0.95">
<Button x:Name="NoteDelete" HorizontalAlignment="Right" VerticalAlignment="Top" Foreground="{x:Null}" Tapped="NoteDelete_Tapped" MinWidth="50" MinHeight="50" Margin="0,0,10,0" BorderBrush="{x:Null}" >
<Button.Background>
<ImageBrush ImageSource="{Binding Delete}"/>
</Button.Background>
</Button>
<Button x:Name="NoteEdit" HorizontalAlignment="Right" VerticalAlignment="Top" FontFamily="Segoe Script" FontSize="24" BorderBrush="{x:Null}" Tapped="NoteEdit_Tapped" Foreground="{x:Null}" MinWidth="50" MinHeight="50" Margin="0,0,10,0">
<Button.Background>
<ImageBrush ImageSource="{Binding Edit}"/>
</Button.Background>
</Button>
</StackPanel>
</Canvas>
</DataTemplate>
</GridView.ItemTemplate>
画像の高さと幅は、それぞれクラスTemplateHeight
とにバインドされています。私はとのためのより良いセッターを持っています。TemplateWidth
Page_Collection
TemplateHeight
TemplateWidth
public static int TemplateWidth
{
get { return m_templateWidth; }
set
{
m_templateWidth = value;
}
}
問題は、というページから画像サイズのサイズを変更する必要があるということGeneral
です。
トグルスイッチを切り替えると、画像のサイズを変更する必要があります。このような
private void OnCompactCategoryToggled(object sender, RoutedEventArgs e)
{
if (compactCateg.IsOn == true)
{
Page_Collection.TemplateHeight = 100;
Page_Collection.TemplateWidth = 350;
}
else
{
Page_Collection.TemplateHeight = 200;
Page_Collection.TemplateWidth = 700;
}
}
AllPageView
ページはにバインドされていPage_Collection
ますが、値は更新されないため、画像サイズは同じです。Genera
lはのaFlyout
ですSettingsPane
。
私はWindows8を初めて使用しますが、これが初めてDataBinding
です。誰かが私がどこで間違っているのか、または私が何かを逃しているのか教えてもらえますか?
編集
これはの背後にあるコードですAllPageView
。Load_PageCollection
クラスのコンストラクターを呼び出します
public async void Load_PageCollection()
{
m_pageConfig = new PageConfig();
Page_Collection[] tmppage = await m_pageConfig.Read_FromJSONFile(App.PAGECONFIG);
List<Page_Collection> tmp;
if (tmppage != null)
{
for (int i = 0; i < tmppage.Length; i++)
{
tmppage[i].UpdateCompletionStatus();
}
tmp = tmppage.ToList();
ObservableCollection<Page_Collection> NoteCol = new ObservableCollection<Page_Collection>(tmp.ToList<Page_Collection>());
PageCollection = NoteCol;
PageLV.DataContext = PageCollection;
m_pageManager.InitilizeWithFileLoc(PageCollection.ToArray());
}
else
{
PageCollection = new ObservableCollection<Page_Collection>();
PageLV.DataContext = PageCollection;// PageLV is the grid view. The gridview, the image and a stackpanel.
}
}