I was wondering if it's possible to make a case or an if statement or a trigger of some sort within the XAML? My goal is to make the column header with the name ID Isvisible = false My columns are autogenerated which makes it a bit more tough. If I can help with making the column visibility please.
<telerik:RadGridView ItemsSource="{Binding AllQueries, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" AutoGenerateColumns="True">
</telerik:RadGridView>
AllQueries is very dynamic, the columns changes based on certain actions but here is a sample.
AllQueries = (from z in ctx.Projects
join y in ctx.ProjectScopes on z.ProjectScope_Id equals y.Id
where (z.StartDate <= StartDateTo && z.EndDate >= EndDateTo && y.Value == "Community Development")
select new {Id = z.Id, z.Created, z.EndDate, z.ProjectName }).ToList();
I would like to display Created, EndDate and ProjectName. I cannot remove ID because it plays a roll on my double click action.
You'll have to explicitly set in the XAML inside the Column Template to disable a certain Column.
<telerik:RadGridView ItemsSource="{Binding AllQueries, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" AutoGenerateColumns="True">
<!-- GridView's Column Template
<telerik:Column IsEnabled="False"> -- I'm not sure what is the exact control name for `Telerik's RadGridView Column` and if it requires setting binding to know what field it will map in the column.
-->
</telerik:RadGridView>
UPDATE
It can be similar to this
<DataGrid Name="dealerList" AutoGenerateColumns="False" ItemsSource="{Binding DealerList}">
<DataGrid.Columns>
<DataGridTextColumn Header="ID" Width="30" Binding="{DealerId}" IsEnabled="False" />
<DataGridTextColumn Header="Name" Width="*" Binding="{DealerName}" />
</DataGrid.Columns>
</DataGrid>
Related
I have an SQL Database, with table Jars and JarTypes. I need to show the data in a DataGrid. I also have to be able to edit the rows. I think a DataGridComboBoxColumn is perfect for the job. How can i populate the ComboBox with JarTypes.Type and put TypeId back into the Jars.TypeId. The tables are stored in DataTables JarsDt and TypeDt
Jars (JarsDt)
JarId (PK)
Amount
TypeId (FK)
JarTypes (TypeDt)
TypeId (PK)
Type
XAML
<DataGrid x:Name="JarDataGrid"
AutoGenerateColumns="False"
IsReadOnly="False"
HorizontalAlignment="Stretch"
Margin="10,35,2,36.8">
<DataGrid.Columns>
<DataGridTextColumn Header="#"
IsReadOnly="True"
Binding="{Binding JarId}" />
<DataGridTextColumn Header="Mengde"
Binding="{Binding Amount}" />
<DataGridComboBoxColumn x:Name="combo"
Header="Glass"
SelectedValueBinding="{Binding TypeId}"
DisplayMemberPath="{Binding Type}"/>
<DataGridTextColumn Header="Mengde levert"
IsReadOnly="True"
Binding="{Binding AmountDelivered}" />
Set the ItemsSource property of the DataGrid to a list of Jars and the ItemsSource property of the ComboBox to a list of JarTypes.
You can do this in XAML using a CollectionViewSource or in code by directly setting JarDataGrid.ItemsSource = ListOfJars.
You need to set the SelectedValuePath property of DataGridComboBoxColumn.
Also DisplayMemberPath is a string property, so does not use binding.
In your case it would be:
<DataGridComboBoxColumn x:Name="combo"
Header="Glass"
DataContext="{StaticResource jarTypesViewSource}"
ItemsSource="{Binding}"
SelectedValueBinding="{Binding TypeId}"
SelectedValuePath="TypeId"
DisplayMemberPath="Type"/>
I'm new to windows mobile apps.
I have a pivot page and inside that there is multiple pivot items.
Inside the pivot item there is list picker which values are hard coded.
If there is more items in list picker all items show in a new page by default.
My issue is since all the item font are too small when opening the screen.
How can I change the font size of list picker items when those are opening.
My code like this.
<toolkit:ListPicker Grid.Row="0" Grid.Column="2" FontSize="21" Header="" Margin="10,12,-157,12" Background="White" Foreground="Black" BorderThickness="1" >
<sys:String>Convenience Eateries (CE)</sys:String>
<sys:String>Grocery Store (GS)</sys:String>
<sys:String>Secondary Network-ASD</sys:String>
<sys:String>Secondary Network-PSD</sys:String>
<sys:String>Cash and Carry</sys:String>
<sys:String>Modern Trade-Convenience Organized</sys:String>
<sys:String>Modern Trade-Grocery independent(SMMT)</sys:String>
<sys:String>HoReCa-Leisure outlets</sys:String>
<sys:String>HoReCa-Sports Clubs</sys:String>
<sys:String>HoReCa-Night Clubs</sys:String>
<sys:String>HoReCa-Karaoke</sys:String>
<sys:String>HoReCa-Casino</sys:String>
<sys:String>HoReCa-Café and Restaurant/Pubs</sys:String>
<sys:String>HoReCa-Other</sys:String>
<sys:String>Military-Welfare Shop</sys:String>
<sys:String>Military-Canteen</sys:String>
<sys:String>Convenience Mobile Outlets</sys:String>
<sys:String>Unconventional Outlets-Wine Stores</sys:String>
<sys:String>Unconventional Outlets-Other</sys:String>
</toolkit:ListPicker>
Try using ListPickerItem children instead of strings. They should have a better default look than shown above:
<toolkit:ListPicker>
<toolkit:ListPickerItem>Bob</toolkit:ListPickerItem>
<toolkit:ListPickerItem>Betty</toolkit:ListPickerItem>
<toolkit:ListPickerItem>Frank</toolkit:ListPickerItem>
<toolkit:ListPickerItem>Frank</toolkit:ListPickerItem>
</toolkit:ListPicker>
To change how the items look in the full mode page, you need to change the ListPicker's FullModeItemTemplate property. Something like this:
<toolkit:ListPicker>
<toolkit:ListPicker.FullModeItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" FontSize="25" />
</DataTemplate>
</toolkit:ListPicker.FullModeItemTemplate>
<sys:String>Convenience Eateries (CE)</sys:String>
<sys:String>Grocery Store (GS)</sys:String>
<!-- Hard coded values go here, just as in your code. -->
</toolkit:ListPicker>
I am writing a Silverlight application which need to show some data.
There are two DataGrids:
First one shown "Users" class. This class contains several fields such as "Name", "Gender", "Grade", "Department", "Fingerprints". "Fingerprints" contains more than one "Fingerprint" Class.
Now I need to link two DataGrid together -- The first one is shown all users, and the second one show the fingerprints of one user which was selected in the first DataGrid.
BTW: I am using WCF Domain Service to supply data source for these two DataGrids.
UPDATE 1:
XAML code:
<sdk:Page.Resources>
<CollectionViewSource x:Key="studentFingerprintsViewSource" Source="{Binding Path=Data.Fingerprints, ElementName=dds_Main}" />
</sdk:Page.Resources>
<riaControls:DomainDataSource x:Name="dds_Main" QueryName="GetStudentsQuery">
<riaControls:DomainDataSource.FilterDescriptors>
<riaControls:FilterDescriptor Operator="Contains" PropertyPath="Number" Value="{Binding Text, ElementName=txt_UserID, Mode=TwoWay}"/>
</riaControls:DomainDataSource.FilterDescriptors>
<riaControls:DomainDataSource.DomainContext>
<ds:AllDomainContext />
</riaControls:DomainDataSource.DomainContext>
</riaControls:DomainDataSource>
<sdk:DataGrid AutoGenerateColumns="True" ItemsSource="{Binding ElementName=dds_Main, Path=Data}" Margin="12,38,8,0" Name="dg_Main" RowDetailsVisibilityMode="VisibleWhenSelected" Height="168" VerticalAlignment="Top" />
<sdk:DataGrid AutoGenerateColumns="True" Height="200" HorizontalAlignment="Left" ItemsSource="{Binding Source={StaticResource studentFingerprintsViewSource}}" Margin="406,320,0,0" Name="fingerprintsDataGrid" RowDetailsVisibilityMode="VisibleWhenSelected" VerticalAlignment="Top" Width="400" />
class Fingerprint
{
int id;
/* something more */
}
Class Student
{
int id;
/* Fingerprints. I forgot the type. All models classes are generated by Entity Model Designer */
/* something more */
}
The first DataGrid can show all students correctly, the latter one always shown nothing...
I have the following code, which i want to programmatically create. Where the i is must be an integer into xaml! This is a sample Code from VISIBLOX.
<Rectangle Margin="20,0,0,5" Height="10" Width="10" Fill="{Binding ElementName=chart, Path=Series[i].LineStroke}" VerticalAlignment="Center" />
<TextBlock Margin="4,0,0,0" Text="{Binding ElementName=chart, Path=Series[i].DataSeries.Title}" />
<TextBlock Margin="4,0,0,0" Text="(" HorizontalAlignment="Left" />
<TextBlock Text="{Binding ElementName=chart, Path=Behaviour.Behaviours[0].CurrentPoints[i].Y, StringFormat=0.00}" Width="38" />
<TextBlock Text=")" HorizontalAlignment="Right" />
I can create a most programmatically but im stucking since 2 days with the Path=Behaviour.Behaviours[0].CurrentPoints[i].Y impossible for me to see how i can programmatically create it!
Thank u for help
Edit
IT's Work
TextBlock txtBlock3 = new TextBlock();
Binding txtBinding3 = new Binding();
txtBinding3.ElementName = "MainChart";
txtBinding3.Path = new PropertyPath("Behaviour.Behaviours[0].CurrentPoints[" + index +"].Y");
txtBlock3.SetBinding(TextBlock.TextProperty, txtBinding3);
txtBlock3.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
Panel.Children.Add(txtBlock3);
Presumably you're going to be building this Binding in a for loop of some sort?
If so, can't you do something like:
Binding b = new Binding { Path = new PropertyPath("Behaviour.Behaviours[0].CurrentPoints[" + i +"].Y”) };
Where the i there is the indexer in the for loop? I'm not sure I fully understand the problem so maybe you could elaborate with a bit more context?
If you’re trying to bind to a different thing depending on what is available in CurrentPoints, you might need to just bind to Benaviour.Behaviours[0] and use a converter to return the correct point’s Y value.
If you need any more help just let me know!
This is a follow up question from an earlier post (here).
I have some 'header' information stored as:
Dictionary<string,string> - where the first string represents the field name, and the second the heading I want displayed.
I have a set of dynamic data that is stored as:
Dictionary<string, object> - where string is the field name.
I bind to this in xaml as:
<data:DataGrid Name="_dataGrid" AutoGenerateColumns="True" IsReadOnly="False" Margin="5" Height="200">
<data:DataGrid.Columns>
<data:DataGridTextColumn Header="Forename" CanUserSort="True" SortMemberPath="Forename"
Binding="{Binding Converter={StaticResource RowIndexConverter},
ConverterParameter=Forename}"/>
<data:DataGridTextColumn Header="Surname" CanUserSort="True" SortMemberPath="Surname"
Binding="{Binding Converter={StaticResource RowIndexConverter},
ConverterParameter=Surname}"/>
<data:DataGridTextColumn Header="Age" CanUserSort="True" SortMemberPath="Age"
Binding="{Binding Converter={StaticResource RowIndexConverter},
ConverterParameter=Age}"/>
<data:DataGridTextColumn Header="Shoesize" CanUserSort="True" SortMemberPath="Shoesize"
Binding="{Binding Converter={StaticResource RowIndexConverter},
ConverterParameter=Shoesize}"/>
</data:DataGrid.Columns>
</data:DataGrid>
Problem 1 I want to autogenerate these columns (using the header information supplied)
Problem 2 I want the columns to be generated based on what datatype they are (i.e. boolean = checkbox)
Problem 3 Ideally I would also like to specify weather a button should exist in the first column or not (i.e. an edit / view button) via databinding
I've used an approach that follows the pattern of this pseudocode
columns = New DynamicTypeColumnList()
columns.Add(New DynamicTypeColumn("Name", GetType(String)))
dynamicType = DynamicTypeHelper.GetDynamicType(columns)
DynamicTypeHelper.GetDynamicType() generates a type with simple properties. See this post for the details on how to generate such a type
Then to actually use the type, do something like this
Dim rows as List(Of DynamicItem)
Dim row As DynamicItem = CType(Activator.CreateInstance(dynamicType), DynamicItem)
row("Name") = "Foo"
rows.Add(row)
dataGrid.DataContext = rows