シナリオ:
私はWinRT/Win8のStore Appで作業しています。ScrollViewの子がウィンドウのサイズを適切に変更していないWinRT
私は内部のカスタムUserControl
子で、ScrollView
を持っている - 1 UserControl
「メイン」の一環として、すべての。 ; - 初期化されるで/に移動してもアプリ幅ないフルスクリーンで - (>子UserControl
ScrollView
で)主UserControl
が
UserControl
は希望の通りScrollView
の全幅にあります。下の画像: - 必要に応じて
- Image 1 - main User Control Opens with Window Fullscreen
- Image 2 - main User Control Opens Starts Half-Width (or any width)
ScrollView
自体は、それがリサイズだ場合でも、Grid
内にあり、アプリケーションウィンドウの幅いっぱいに保持します。
問題:
私がいる問題は、私は水平にアプリケーションウィンドウのサイズを変更する場合、子UserControl
は親ScrollView
年代と同じ幅を保持していないということです。
これにより、ScrollView
には水平スクロールバーが表示されます。これは望ましくありません。
私は(Image 2のように)no水平スクロールバーでScrollView
の幅の内側に拘束されることを子供の幅を維持したいです。
マークアップは(私は読みやすくするためにストリップダウンしている)次のようになります。
<Grid>
<!-- Some row/column definitions in here -->
...
<!-- A header TextBlock -->
...
<ScrollViewer x:Name="scrlTableRows" Grid.ColumnSpan="3" Grid.Row="1"
HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"
Padding="66,0,66,40" ZoomMode="Disabled">
<local:MyCustomUserControl Margin="0,10,0,10" HorizontalAlignment="Stretch" />
</ScrollViewer>
...
<!-- Just a button here-->
</Grid>
私はすでに(子カスタムUserControl
上)設定を試してみました:
Width="{Binding Path=ActualWidth, ElementName=scrlTableRows}"
子供のは、の全幅でに設定されていません私を与えることWidth="{Binding Path=Width, ElementName=scrlTableRows}"
をスクロールバー子は、「親の全幅でスタートを行いますが、doesnの - (私は必要なものである)で開始する、とその親のどちらかで幅を変更しませんトンサイズを変更 - 私を与えることは、私も他の多くのHorizontalAligment
とWidth
の特性の中で、(ScrollView
以内)Grid
内UserControl
を配置しようとしているをスクロールバー。
すべては無駄です。
StackOverflowで他の似たような状況や答えが他の有用な人と一緒に働いたことはありません。
明らかに、私は垂直スクロールバーが必要です - 明らかなように;誰かが尋ねる前に。
誰でも私に何かポインタを教えてもらえますか?
更新:ここ
があるカスタムUserControl
のXAML、@LovetoCodeによって要求される:
<UserControl *usual user control declaritive stuff in here*>
<UserControl.Resources>
<CollectionViewSource x:Key="FieldViewModelsSource" Source="{Binding ItemToEdit.FieldViewModels}"/>
<datatemplateselectors:FieldViewModelDataTemplateSelector
x:Key="FieldViewModelDataTemplateSelector"
AudioFieldTemplate="{StaticResource TableRowAudioFieldDataTemplate}"
CheckboxFieldTemplate="{StaticResource TableRowCheckboxFieldDataTemplate}"
DatasetFieldTemplate="{StaticResource TableRowDatasetFieldDataTemplate}"
DateFieldTemplate="{StaticResource TableRowDateFieldDataTemplate}"
DateTimeFieldTemplate="{StaticResource TableRowDateTimeFieldDataTemplate}"
DropdownFieldTemplate="{StaticResource TableRowDropdownFieldDataTemplate}"
FileFieldTemplate="{StaticResource TableRowFileFieldDataTemplate}"
GpsFieldTemplate="{StaticResource TableRowGpsFieldDataTemplate}"
GridFieldTemplate="{StaticResource TableRowGridFieldDataTemplate}"
ImageFieldTemplate="{StaticResource TableRowImageFieldDataTemplate}"
LabelFieldTemplate="{StaticResource TableRowLabelFieldDataTemplate}"
MultichoiceCheckboxFieldTemplate="{StaticResource TableRowMultichoiceCheckboxFieldDataTemplate}"
RadioFieldTemplate="{StaticResource TableRowRadioFieldDataTemplate}"
RangeSliderFieldTemplate="{StaticResource TableRowRangeSliderFieldDataTemplate}"
SignatureFieldTemplate="{StaticResource TableRowSignatureFieldDataTemplate}"
SplitterFieldTemplate="{StaticResource TableRowSplitterFieldDataTemplate}"
TextFieldTemplate="{StaticResource TableRowTextFieldDataTemplate}"
TextareaFieldTemplate="{StaticResource TableRowTextareaFieldDataTemplate}"
TimeFieldTemplate="{StaticResource TableRowTimeFieldDataTemplate}"
VideoFieldTemplate="{StaticResource TableRowVideoFieldDataTemplate}"/>
</UserControl.Resources>
<Grid>
<ItemsControl ItemsSource="{Binding Source={StaticResource FieldViewModelsSource}}"
ItemTemplateSelector="{StaticResource FieldViewModelDataTemplateSelector}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Margin="10,0,10,0" Orientation="Vertical" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</Grid>
</UserControl>
注UserControl
資源でDataTemplate
リソースがロードされているカスタムUserControl
sがあること(my original image 1のような)ViewModelのオブジェクトに基づいています。
試してみてくださいHorizontalContentAlignment = "ストレッチ" – Archana
どのコントロールですか?カスタムのものについては、私はすでに持っていると思います... –
On –
Archana