Telerik Forums
UI for WPF Forum
2 answers
108 views
2 related tables. Let's call them 'Players" and "Teams"
they are related by a field TeamID

when editing a Player I want to able to use a CboBox to edit his team

Importantly is that I am Editing not creating new players

when I select an existing  player the WPF Form should display that players current Team in a combobox

and allow me to change it (ie it's populated with all teams)

I'm getting confused with databinding in WPF. My data is EDMX Data which I am querying into an observable collection

I used to do this stuff so easily in Windows Forms. I just can't seem to grasp what is happening in WPF

Anybody ?
Will Ferguson
Top achievements
Rank 1
 answered on 04 Sep 2010
6 answers
217 views
How do I set which item is maximized.  I'm databinding the items collection to a list that I get from a WCF call, this list is refreshed every 10 seconds.  What I need to do is get the index of the selected item, so when i rebind I can re select the item at that index.

I can get the index of the selected item, and in the "TileView_DataContextChanged" event handler I'm doing the following
        private void TileView_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) 
        { 
            if(!TileView.Items.IsEmpty) 
                TileView.MaximizedItem = TileView.Items[Index]; 
        } 


it sets the maximized item correctly, but that doesn't seem to actually maximize that item.  Am I confused about how this should work?
I read in the documentation that the RadTileViewItem has a property to change its maximized setting, but I can't find where to get a hold of a reference to that class.

Thanks

Joshua
Garry Clark
Top achievements
Rank 1
 answered on 04 Sep 2010
2 answers
1.1K+ views
Hi,

I am creating a windows explorer type application using WPF, and want to use the icons that are within the Shell32.dll so that it matches what is in windows explorer. I have tried several different methods assigning the icon to the radtreeviewitem and none have worked.

Here is an excerpt from my code I am first checking to see if an image is contained in the imagelist before adding a new image to the list:

                    if (images.Images["Folders"] == null)
                    {
                        images.Images.Add("Folders", (System.Drawing.Icon)GetIcon(drive.Name, 0));
                    }
                    item.DefaultImageSrc = "Folders";

Here is the getIcon method:
        private object GetIcon(string path, int openclose)
        {
            IntPtr hImgSmall;
            SHFILEINFO shinfo = new SHFILEINFO();

            hImgSmall = Win32.SHGetFileInfo(path, 0, ref shinfo, (uint)Marshal.SizeOf(shinfo), Win32.SHGFI_ICON | Win32.SHGFI_SMALLICON);

            return System.Drawing.Icon.FromHandle(shinfo.hIcon);
        }

I am not sure if this is even possible using the radtreeview of WPF. I moved this code into a program that was built using winforms and it works perfectly.

Thanks,
Jonathan
Civbaron
Top achievements
Rank 1
 answered on 03 Sep 2010
4 answers
240 views
Hello,
I can't figure out the binding to the HierarchicalDataTemplate.
I'm able to populate the Childnodes fine., but no luck with the parentNodes

Any thoughts would be great

Regards,
Rick Mueller
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      
        <Table>
            <CompanyName>Digital Kitchen1</CompanyName>
            <Location>Eden Prairie1</Location>
            <ContactName>Rick Mueller</ContactName>
            <ContactTitle>PrepCook</ContactTitle>
            <EmpImage>male.jpg</EmpImage>
            <StDate>15664</StDate>
            <EmpId>156</EmpId>
        </Table>
        <Table>
            <CompanyName>Digital Kitchen</CompanyName>
            <Location>Eden Prairie</Location>
            <ContactName>Willie The Dog</ContactName>
            <ContactTitle>LineCook</ContactTitle>
            <EmpImage>male.jpg</EmpImage>
            <StDate>40535</StDate>
            <EmpId>156</EmpId>
        </Table>
    <Table>
            <CompanyName>Digital Kitchen</CompanyName>
            <Location>Eden Prairie</Location>
            <ContactName>Jose Sosa</ContactName>
            <ContactTitle>Dishwasher</ContactTitle>
            <EmpImage>male.jpg</EmpImage>
            <StDate>40535</StDate>
            <EmpId>156</EmpId>
        </Table>
        <Table>
            <CompanyName>Digital Kitchen</CompanyName>
            <Location>Eden Prairie</Location>
            <ContactName>Maria Anders</ContactName>
            <ContactTitle>BroilerCook</ContactTitle>
            <EmpImage>female.jpg</EmpImage>
            <StDate>40535</StDate>
            <EmpId>156</EmpId>
        </Table>
</NewDataSet>
<Window.Resources>
          
        <XmlDataProvider x:Key="Contact"
            Source="xmlData/Employee.xml"
            XPath="NewDataSet/Table"/>
          
    
  
        <HierarchicalDataTemplate 
                         x:Name="TreeData" 
                         DataType="XmlDataProvider"
                         ItemsSource="{Binding Contact}">
             <TextBlock Text="{Binding XPath=ContactTitle}" 
                        Foreground="Black" 
                        FontWeight="Bold"
                        FontSize="15" />
        </HierarchicalDataTemplate>
          
                 <DataTemplate x:Key="Team">
                  <TextBlock Text="{Binding XPath=ContactName}" 
                           Foreground="Blue" 
                           FontWeight="Bold"
                           FontSize="9" />
                  </DataTemplate>
  
  
    </Window.Resources>
  
    <Grid>
        <telerik:RadTreeView 
            Height="311" HorizontalAlignment="Left" 
            Margin="320,0,0,0" Name="radTreeView1" 
            VerticalAlignment="Top" Width="183"
            ItemsSource="{Binding Source={StaticResource Contact},XPath=ContactTitle}"
            ItemTemplate="{StaticResource Team}"/>
</Grid>
Rick Mueller
Top achievements
Rank 1
 answered on 03 Sep 2010
5 answers
311 views
Hello,

I tried every which way to get the background transparent. I like the Black Office Headers. I have the foreground white. For some reason the backgound is still white

Any thoughts>?

Thanks
Rick Mueller
Vanya Pavlova
Telerik team
 answered on 03 Sep 2010
0 answers
171 views
Hi, 

I'm looking for a ListView of  [Textbox + Checkbox]  Items
But i can't find any Telerik listview component.

I need to have my TextBox Editable on double click event on the Item..
I can't do this with the basic ListView.

Do you have any component to achieve this purpose ?

Thank you.
Tgaud
Top achievements
Rank 1
 asked on 03 Sep 2010
6 answers
304 views
Hi,

I am having a scenario that I need to enter a new value to the field or select a existing value in the combo box. On change of the cell selection I need to insert or update the value in the database.

The issue is

Im able to enter new value to the combobox ,But when I selecting the adjacent cell of the same edited row after editing, the entered value disappears.But When I selecting a cell other than the edited row  then Im able to get the changes as required.


Thank you in advance

Nedyalko Nikolov
Telerik team
 answered on 03 Sep 2010
1 answer
145 views
Hi,

I have a linear gauge with two linear scales. One scale has a range list and a bar indicator, and the other one has a marker indicator and two custom tick marks. The problem is that I don't know how to create the custom tick marks. What I need is two simple rectangular tick marks, one red and the other yellow.
To get started, I tried to use an example from another thread, one with °C label, but i keep getting the following error:

System.Windows.Data Error: 25 : ItemTemplate and ItemTemplateSelector are not valid for item.; Type='CustomTickMark'

The code with °C label is posted below.

 <control:RadGauge MaxWidth="100"
                                          telerikControls:StyleManager.Theme="Windows7"
                                          BorderThickness="0"
                                          BorderBrush="Transparent"
                                          VerticalAlignment="Stretch"
                                          Height="Auto"
                                          Grid.Row="0"
                                          Grid.Column="0"
                                          Margin="5"
                                          x:Name="radGauge">
                            <telerik:LinearGauge Height="Auto"
                                                 Grid.Row="0"
                                                 Grid.Column="0"
                                                 x:Name="LinearGaugeDay">
                                <telerik:LinearScale x:Name="linearScaleDay"
                                                     Min="0"
                                                     Max="{Binding Path=MaximumProductivity}"
                                                     MajorTicks="1"
                                                     MiddleTicks="10"
                                                     MinorTicks="1"
                                                     Left="0.5"
                                                     Top="0.1"
                                                     RelativeHeight="0.81"
                                                     FontSize="9">
                                    
                                    <telerik:LinearScale.MajorTick>
                                        <telerik:MajorTickProperties Location="OverCenter"
                                                                     x:Name="MajorTickProperties0" />
                                    </telerik:LinearScale.MajorTick>
                                    <telerik:LinearScale.MiddleTick>
                                        <telerik:MiddleTickProperties Location="OverCenter"
                                                                      Length="0.07"
                                                                      x:Name="MiddleTickProperties0" />
                                    </telerik:LinearScale.MiddleTick>
                                    <telerik:LinearScale.MinorTick>
                                        <telerik:MinorTickProperties Location="OverCenter"
                                                                     Length="0.055"
                                                                     x:Name="MinorTickProperties0" />
                                    </telerik:LinearScale.MinorTick>

                                    <telerik:LinearScale.Label>
                                        <telerik:LabelProperties x:Name="LabelRightx0"
                                                                 FontSize="12"
                                                                 FontFamily="Arial"
                                                                 Foreground="White"
                                                                 Offset="0.02"
                                                                 Location="Inside" />
                                    </telerik:LinearScale.Label>

                                    <telerik:RangeList x:Name="RangeList0">
                                        <telerik:LinearRange Min="0"
                                                             Max="{Binding Path=MinimumProductivity}"
                                                             StartWidth="0.02"
                                                             EndWidth="0.02"
                                                             Location="Inside"
                                                             Style="{StaticResource RangePalette_Red}"
                                                             x:Name="LinearRange0" />
                                        <telerik:LinearRange Min="{Binding Path=MinimumProductivity}"
                                                             Max="{Binding Path=MediumProductivity}"
                                                             StartWidth="0.02"
                                                             EndWidth="0.02"
                                                             Location="Inside"
                                                             Style="{StaticResource RangePalette_Yellow}"
                                                             x:Name="LinearRange1" />
                                        <telerik:LinearRange Min="{Binding Path=MediumProductivity}"
                                                             Max="{Binding Path=MaximumProductivity}"
                                                             StartWidth="0.02"
                                                             EndWidth="0.02"
                                                             Location="Inside"
                                                             Style="{StaticResource RangePalette_Green}"
                                                             x:Name="LinearRange2" />
                                    </telerik:RangeList>
                                    

                                    <telerik:IndicatorList x:Name="IndicatorList0">
                                        <telerik:LinearBar Name="linearBar1"
                                                           Value="{Binding Path=DayProductivity}"
                                                           StartWidth="0.04"
                                                           EndWidth="0.04"
                                                           Location="OverCenter"
                                                           UseRangeColor="True"
                                                           IsAnimated="True" />

                                    </telerik:IndicatorList>
                                </telerik:LinearScale>

                                <telerik:LinearScale x:Name="linearScaleDayLeft"
                                                     Min="0"
                                                     Max="{Binding Path=MaximumProductivity}"
                                                     MajorTicks="10"
                                                     MiddleTicks="0"
                                                     MinorTicks="0"
                                                     Left="0.5"
                                                     Top="0.1"
                                                     RelativeHeight="0.81"
                                                     FontSize="9">
                                    <telerik:LinearScale.MajorTick>
                                        <telerik:MajorTickProperties Location="OverCenter"
                                                                     x:Name="MajorTickProperties1" />
                                    </telerik:LinearScale.MajorTick>
                                    <telerik:LinearScale.MiddleTick>
                                        <telerik:MiddleTickProperties Location="OverCenter"
                                                                      Length="0.07"
                                                                      x:Name="MiddleTickProperties1" />
                                    </telerik:LinearScale.MiddleTick>
                                    <telerik:LinearScale.MinorTick>
                                        <telerik:MinorTickProperties Location="OverCenter"
                                                                     Length="0.055"
                                                                     x:Name="MinorTickProperties1" />
                                    </telerik:LinearScale.MinorTick>

                                    <telerik:LinearScale.Label>
                                        <telerik:LabelProperties x:Name="LabelLeftx0"
                                                                 Offset="0.02"
                                                                 Location="Outside" />
                                    </telerik:LinearScale.Label>

                                    <telerik:TickList>
                                        <telerik:CustomTickMark Value="-7"
                                                                Location="Inside"
                                                                Offset="-0.02">
                                            <telerik:CustomTickMark.Template>
                                                <ControlTemplate>
                                                    <ContentPresenter>
                                                        <ContentPresenter.Content>
                                                            <Canvas>
                                                                <TextBlock HorizontalAlignment="Center"
                                                                           FontWeight="Bold"
                                                                           FontSize="14"
                                                                           Foreground="White"
                                                                           Text="°C" />
                                                            </Canvas>
                                                        </ContentPresenter.Content>
                                                    </ContentPresenter>
                                                </ControlTemplate>
                                            </telerik:CustomTickMark.Template>
                                            <telerik:CustomTickMark.ItemTemplate>
                                                <DataTemplate />
                                            </telerik:CustomTickMark.ItemTemplate>
                                        </telerik:CustomTickMark>
                                    </telerik:TickList>


                                  

                                    <telerik:IndicatorList x:Name="IndicatorList1">
                                        <telerik:Marker x:Name="gauge_marker_Day"
                                                        RelativeHeight="0.04"
                                                        RelativeWidth="0.04"
                                                        FontSize="12"
                                                        FontFamily="Arial"
                                                        Foreground="White"
                                                        Offset="0.02"
                                                        Location="CenterOutside"
                                                        IsAnimated="True"
                                                        Value="{Binding Path=DayProductivity}">
                                        </telerik:Marker>
                                    </telerik:IndicatorList>
                                </telerik:LinearScale>

                            </telerik:LinearGauge>
                        </control:RadGauge>

What am I doing wrong? Do you have any suggestions for this?

Regards,
Ali
Andrey
Telerik team
 answered on 03 Sep 2010
2 answers
104 views
In our scenario the data structure we need to bind to looks something like this (simplified):

public interface IEvent
{
    ObservableCollection<IRow> Rows { get; }
    ObservableCollection<IColumn> Columns { get; }
}
 
public interface IColumn
{
    DataTemplate Template { get; }
}
 
public interface IRow
{
    ObservableCollection<ICell> Cells { get; }
}
 
public interface ICell
{
    string Value { get; }
}

The IEvent is the DataContext for the grid.

From what I can tell this scenario isn't supported through XAML, so I'm building up the grid with its list of columns in code-behind.  I can set up the DataMemberBinding for each column to something like this:

column.DataMemberBinding = new Binding("Cells[" + columnIndex + "].Value");

It's not ideal, but it works correctly and I get the ICell's value in the cell on the grid.  Now I want to use a custom DataTemplate for each column.  This is where I am struggling to find a neat solution.

Let's say we have a type implementing ICell that exposes some extra information:

public class CustomCell : ICell
{
    public string Value { get; }
    public string CustomData { get; set; }
}

Let's also assume this is implementing INotifyPropertyChanged.  My custom DataTemplate for a cell might look something like this:

<StackPanel>
    <TextBlock Text="{Binding Value}" FontWeight="Bold" Foreground="Green" />
    <TextBlock Text="{Binding CustomData}" FontWeight="Bold" Foreground="Red" />
</StackPanel>

But this won't work because the data context for the template is the IRow, not the ICell.  I think can't create a template based on the IRow because the template doesn't know the column index:

<StackPanel>
    <TextBlock Text="{Binding Cells[???].Value}" FontWeight="Bold" Foreground="Green" />
    <TextBlock Text="{Binding Cells[???].CustomData}" FontWeight="Bold" Foreground="Red" />
</StackPanel>

This is where I'm getting a bit stuck.  Is there a way to achieve what I want with RadGridView?  We can change our data structures if necessary.

To give a bit of background, each column is defined by an add-in and the add-in also provides the DataTemplate for its data.  This is why the columns need to be defined at run time and the template is concerned about the cell and not the entire row.

Thanks,
James.

James
Top achievements
Rank 1
 answered on 03 Sep 2010
4 answers
91 views
Hi,

I'm using Blend and i would like to add a built-in xaml based behaviour to independent items of the grid, like the "play sound" behaviour for a clicked cell.

How can i implement that with a datagrid binded to a XML file ? Is there even a way to do that ?

thanks for any information
.
bob
Top achievements
Rank 1
 answered on 03 Sep 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?