Click here to Skip to main content
15,887,683 members
Home / Discussions / WPF
   

WPF

 
QuestionDisappearing namespace? [modified] Pin
Alisaunder26-Aug-11 7:32
Alisaunder26-Aug-11 7:32 
AnswerRe: Disappearing namespace? [modified] Pin
Saksida Bojan27-Aug-11 10:50
Saksida Bojan27-Aug-11 10:50 
GeneralRe: Disappearing namespace? Pin
Alisaunder27-Aug-11 11:47
Alisaunder27-Aug-11 11:47 
GeneralRe: Disappearing namespace? Pin
Alisaunder27-Aug-11 17:25
Alisaunder27-Aug-11 17:25 
GeneralRe: Disappearing namespace? Pin
Saksida Bojan27-Aug-11 19:30
Saksida Bojan27-Aug-11 19:30 
GeneralRe: Disappearing namespace? Pin
Alisaunder28-Aug-11 0:32
Alisaunder28-Aug-11 0:32 
GeneralRe: Disappearing namespace? Pin
Alisaunder30-Aug-11 5:05
Alisaunder30-Aug-11 5:05 
QuestionWPF Pie Chart Question Pin
#realJSOP26-Aug-11 7:30
mve#realJSOP26-Aug-11 7:30 
I'm building a pie chart (from the WPF Toolkit). Here's the code:

C#
public Chart ChartObject;

//--------------------------------------------------------------------------------
protected void MakePie(List<RepItem> data, string seriesTitle, string yProperty)
{
    DisplayCategories categories = new DisplayCategories();
    foreach (RepItem item in data)
    {
        categories.Add(item.Category);
    }
    System.Collections.ObjectModel.Collection<ResourceDictionary> palette = MakePalette(categories);
    this.ChartObj.Palette = palette;

    PieSeries series = new PieSeries()
    {
        ItemsSource = data,
        Title = seriesTitle,
        DependentValueBinding = new System.Windows.Data.Binding(yProperty),
        IndependentValueBinding = new System.Windows.Data.Binding("Category"),
        TransitionDuration = new TimeSpan(0),
    };
    //Style style = new Style(typeof(PieDataPoint));
    //ControlTemplate template = Application.Current.Resources["PieDataTemplate"] as ControlTemplate;
    //if (template != null)
    //{
    //    SetStyleProperty(style, ColumnDataPoint.TemplateProperty, template);
    //}
    //series.DataPointStyle = style;
    //series.Palette = palette;
    this.ChartObj.Series.Add(series);
}


I have to build the palette manually because the number of values represented in the pie isn't necessarily the same, and they values are sorted from lowest to highest before creating the series. The end result is that the pie slice color must always be the correct color for the associated category regardless of that category's position in the pie.

In any case, that part works great. However, I decided I wanted custom tooltips, so I created a custom ControlTemplate in the app resources:

<ControlTemplate x:Key="PieDataTemplate" TargetType="wtkchart:PieDataPoint">
    <Grid>
        <Path x:Name="Slice"
              Data="{TemplateBinding Geometry}"
              Fill="{TemplateBinding Background}"
              Stroke="{TemplateBinding BorderBrush}">
            <ToolTipService.ToolTip>
                <StackPanel>
                    <ContentControl Content="{Binding Path=Category}" FontSize="12" />
                    <ContentControl Content="{TemplateBinding FormattedDependentValue,
                                              Converter={StaticResource TooltipValueFormatter}}"
                                    FontWeight="Bold" FontSize="14" />
                    <ContentControl Content="{TemplateBinding FormattedRatio}"/>
                </StackPanel>
            </ToolTipService.ToolTip>
        </Path>
    </Grid>
</ControlTemplate>


If I uncomment out the code in the c# code, I get the tooltip I want, but all of the pie slices turn orange. If I re-comment the code, the tooltip isn't right, but the colors are. I THINK I want to change the binding on the Fill property in the control template, but I don't know exactly how to bind that with the parent chart's Palette property.

Any help?
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997


AnswerRe: WPF Pie Chart Question [modified] Pin
Abhinav S26-Aug-11 8:23
Abhinav S26-Aug-11 8:23 
GeneralRe: WPF Pie Chart Question Pin
#realJSOP26-Aug-11 8:50
mve#realJSOP26-Aug-11 8:50 
GeneralRe: WPF Pie Chart Question Pin
#realJSOP28-Aug-11 8:39
mve#realJSOP28-Aug-11 8:39 
GeneralRe: WPF Pie Chart Question Pin
Abhinav S28-Aug-11 20:10
Abhinav S28-Aug-11 20:10 
GeneralRe: WPF Pie Chart Question Pin
#realJSOP29-Aug-11 2:42
mve#realJSOP29-Aug-11 2:42 
QuestionDataGrid cell drag Pin
Saboureau26-Aug-11 2:47
Saboureau26-Aug-11 2:47 
QuestionRoutedUICommands vs ICommand. When & Why Pin
Vincent Beek25-Aug-11 20:57
Vincent Beek25-Aug-11 20:57 
AnswerRe: RoutedUICommands vs ICommand. When & Why Pin
SledgeHammer0126-Aug-11 5:03
SledgeHammer0126-Aug-11 5:03 
GeneralRe: RoutedUICommands vs ICommand. When & Why Pin
Vincent Beek26-Aug-11 6:53
Vincent Beek26-Aug-11 6:53 
GeneralRe: RoutedUICommands vs ICommand. When & Why Pin
SledgeHammer0126-Aug-11 7:00
SledgeHammer0126-Aug-11 7:00 
GeneralRe: RoutedUICommands vs ICommand. When & Why Pin
Vincent Beek26-Aug-11 7:08
Vincent Beek26-Aug-11 7:08 
GeneralRe: RoutedUICommands vs ICommand. When & Why Pin
SledgeHammer0126-Aug-11 7:27
SledgeHammer0126-Aug-11 7:27 
GeneralRe: RoutedUICommands vs ICommand. When & Why Pin
#realJSOP26-Aug-11 7:56
mve#realJSOP26-Aug-11 7:56 
GeneralRe: RoutedUICommands vs ICommand. When & Why Pin
SledgeHammer0126-Aug-11 8:35
SledgeHammer0126-Aug-11 8:35 
GeneralRe: RoutedUICommands vs ICommand. When & Why Pin
Vincent Beek26-Aug-11 9:50
Vincent Beek26-Aug-11 9:50 
GeneralRe: RoutedUICommands vs ICommand. When & Why Pin
SledgeHammer0126-Aug-11 10:09
SledgeHammer0126-Aug-11 10:09 
GeneralRe: RoutedUICommands vs ICommand. When & Why Pin
Vincent Beek26-Aug-11 21:38
Vincent Beek26-Aug-11 21:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.