I was at a dead end trying to convert the following code to pure C #. This XAML code from the Cavanaghs blog on how to make rounded corners on anything. The code works, but I need to convert it to C #, since I need it to be dynamic in some cases. If you could help, that would be great.
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType='{x:Type ListViewItem}'>
<Grid>
<Border CornerRadius="15" Name="mask" Background="White"/>
<StackPanel Background="Beige">
<StackPanel.OpacityMask>
<VisualBrush Visual="{Binding ElementName=mask}"/>
</StackPanel.OpacityMask>
<GridViewRowPresenter Content="{TemplateBinding Content}" Columns="{TemplateBinding GridView.ColumnCollection}"/>
<TextBlock Background="LightBlue" Text="{Binding News}" />
</StackPanel>
</Grid>
</ControlTemplate>
</Setter.Value>
So far I have the following, but I am getting errors.
FrameworkElementFactory border = new FrameworkElementFactory(typeof(Border));
border.SetValue(Border.BackgroundProperty, Brushes.White);
border.SetValue(Border.CornerRadiusProperty, new CornerRadius(8, 8, 8, 8));
border.SetValue(Border.NameProperty, "roundedMask");
As far as I can tell, I cannot make VisualBrush as FrameworkElementFactory (crash), but if I declare it as a regular VisualBrush element I can not pass border as Visual with its FrameworkElementFactory.
I'm just lost, any help would be appreciated. Thanks for any help
source
share