2011-07-29 10 views
0

격자 또는 행의 이름을 정의 함에도 불구하고 ListBox 내에서 격자 나 행에 액세스하는 데 어려움이 있습니다. 일부 매개 변수가 SharePoint browsable 속성에서 Silverlight 컨트롤로 전달 될 때 새로운 MaxHeight를 해당 행 중 하나에 설정하려고합니다.데이터 템플릿 내의 격자 행 속성 액세스 및 수정

원하는 효과를 얻으려면 어떻게해야합니까? 아마도 바인딩? Page.xaml @

: Page.xaml.cs @

<ListBox ItemsSource="{Binding}" DataContext="" x:Name="NewsList" SelectionChanged="NewsList_SelectionChanged" SelectionMode="Single" Width="580" Height="360" VerticalAlignment="Top" HorizontalAlignment="Center" > 
            <ListBox.ItemTemplate> 
             <DataTemplate >          
                           <Grid Height="110" Width="540" x:Name="StaffNewsBodyHeight"> 
                <Grid Height="110" Width="540"> 
               <Grid.RowDefinitions> 
                <RowDefinition Height="15" /> 
                <RowDefinition Height="{Binding StaffNewsBodyHeight}" /> 
                <RowDefinition Height="15" /> 
               </Grid.RowDefinitions>             <Grid.ColumnDefinitions> 
                 <ColumnDefinition Width="82" /> 
                 <ColumnDefinition Width="*" /> 
                </Grid.ColumnDefinitions>            

                <Border CornerRadius="2" BorderThickness="2" BorderBrush="Gray" Height="82" Width="82" Background="LemonChiffon" VerticalAlignment="Center" HorizontalAlignment="Center" Grid.RowSpan="3" Grid.Column="0" >             
                 <Image Source="{Binding NewsThumbnail}" Style="{StaticResource ThumbNailPreview}" /> 
                </Border> 
                <TextBlock x:Name="NewsTitle" FontFamily="Arial" FontWeight="bold" TextDecorations="Underline" Text="{Binding Title}" Style="{StaticResource TitleText}" Grid.Row="0" Grid.Column="1"/>           
          <TextBlock x:Name="NewsBody" FontFamily="Arial" Text="{Binding NewsBody}" Margin="5" Style="{StaticResource DescriptionBlock}" Grid.Row="1" Grid.Column="1" /> 



                <StackPanel Orientation="Horizontal" Grid.Row="2" Grid.Column="1" Margin="3,3,3,3"> 
                 <TextBlock Text="Published By:" HorizontalAlignment="Left" VerticalAlignment="Bottom" Foreground="Gray" FontWeight="Bold" FontSize="9" /> 
                 <TextBlock Text="{Binding PublishedBy}" HorizontalAlignment="Left" VerticalAlignment="Bottom" Foreground="Gray" FontWeight="Bold" FontSize="9" /> 
                 <TextBlock Text="{Binding DatePublished}" HorizontalAlignment="Left" VerticalAlignment="Bottom" Foreground="Gray" FontWeight="Bold" FontSize="9" />              
                </StackPanel>             
               </Grid>          
             </DataTemplate> 
            </ListBox.ItemTemplate> 
           </ListBox> 

:

if (!string.IsNullOrEmpty(_setLength)) 
     {    
      StaffNews test = new StaffNews(); 

      //assign new height to gridrow of NewsBody 
      if (_setLength.Contains("_3")) 
       test.StaffNewsBodyHeight.Equals(200); 
     } 

답변

0

내가 StaffNews 오른쪽 목록에서 한 항목을 나타내는 있다고 생각? 이 경우

, 속성에 값을 할당 할 수는 사용

test.StaffNewsBodyHeight = 200; 

당신의 조각의 마지막 줄을 바꿀 수 있습니다.

[P.S. - StaffNewsBodyHeight는 종속성 속성이 StaffNews에 정의되어 있습니까?]

+0

감사합니다. btw. 작동하는 해결 방법을 찾았습니다. 매우 감사! :) – brainsfrying