0
コードコントロールからContentControl内部からグリッド(listBoxGrid)にアクセスしようとするのが非常に困難です。どんな助けや指針も素晴らしいでしょう!WPF AccessControl内のアクセスコントロール
おかげ ライアン
<Style x:Key="ccTemplate" TargetType="{x:Type ContentControl}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ContentControl}">
<Grid x:Name="listBoxGrid" TextOptions.TextFormattingMode="Display">
<Grid.RowDefinitions>
<RowDefinition Height="200*"/>
<RowDefinition Height="60" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="80" />
<ColumnDefinition Width="80" />
<ColumnDefinition Width="80" />
<ColumnDefinition Width="80" />
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid Grid.ColumnSpan="6" >
<ContentPresenter />
</Grid>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="{x:Type control:ListBoxControl}" TargetType="{x:Type control:ListBoxControl}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<ContentControl Style="{StaticResource ccTemplate}" x:Name="cc">
<telerikNavigation:RadTreeView
Name="mainList"
ItemsSource="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ItemsSource}"
ItemTemplate="{DynamicResource MainDataTemplate}"
ItemContainerStyle="{DynamicResource MainStyle}"
MinWidth="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=MinWidth}"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
BorderBrush="#FF00569F"
Background="{DynamicResource ListItemBackground}"
BorderThickness="1"
SelectionMode="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectionMode, FallbackValue=Single}"
IsDragDropEnabled="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsDragDropEnabled, FallbackValue=False}"
IsDropPreviewLineEnabled="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsDropPreviewLineEnabled, FallbackValue=True}"
AllowDrop="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=AllowDrop, FallbackValue=True}"
>
</telerikNavigation:RadTreeView>
</ContentControl>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
私は
Grid myGrid = (Grid)Template.FindName("listBoxGrid", this);
を試してみましたが、しかし、それは動作するようには思えません。
OnApplyTemplateオーバーライドで、グリッドとしてmyGrid = GetTemplateChild( "listBoxGrid")を試しました。それでもmyGridはnullです。 – Ryan
実際、私が書いたことはSilverlightのみに適用され、WPFではTemplate.FindName()を使用できるはずだということがわかりました。問題は他の場所にあります。 ContentControlの拡張クラスでメソッドを呼び出そうとしましたか? – dain
私の小さな問題を見て、私の問題を見てください。あなたが好きなら:) http://www.vbninja.com/XAMLGridError.zip – Ryan