我有一個包含一個togglebutton的數據模板的gridview。 Gridview中的項目的數據模板中有一個網格,並帶有一個程式化的切換按鈕。 togglebutton的樣式位於Grid.Resources中。它工作正常,但是當我將樣式從Grid.Resources移動到Page.Resources或App.xaml時,樣式中定義的按鈕內的內容將從所有格中消失,除了gridview中第一次出現按鈕。這裏是風格:風格僅適用於Grid.Resources之外的第一次出現。
<Style TargetType="ToggleButton" x:Key="teststyle">
<Setter Property="Padding" Value="0"/>
<Setter Property="Content">
<Setter.Value>
<Path HorizontalAlignment="Center" Stroke="Black" StrokeThickness="1.25" VerticalAlignment="Center" Height="9" Width="9" Stretch="Uniform" Fill="Black" Data="M 0,0 -11.78,-11.779 0,-23.561 l 1.061,1.061 -9.97,9.971 21.064,0 0,1.5 -21.064,0 9.97,9.968 L 0,0 Z" RenderTransformOrigin="0.5,0.5" >
<Path.RenderTransform>
<CompositeTransform Rotation="-90"/>
</Path.RenderTransform>
</Path>
</Setter.Value>
</Setter>
</Style>
這裏是行爲的截圖:http://imgur.com/a/8iZaD頂部圖像是當風格定位於Grid.Resources原來,當風格被移到底部。
您是否明確地將ToggleButton樣式設置爲此StaticResource項(在您的數據模板中)? –
@igrali這是我的ToggleButton聲明在數據模板中的樣子:' ' –
justanotherxl