Custom Config Section - web-config

I am new to VB.Net. I have requirements that I need to create custom config section. I have read some documents but I can't make it work. Appreciate any help.
I need to read in config section with structure like this.
<configSections>
<section name="reportingTabCollectionSection" type="mydll.ReportingTabSection, mydll"/>
</configSections>
<reportingTabCollectionSection>
<reportingTabCollection>
<reportingTab tabName="Parent Tab 1" visible="true">
<reportingTab tabName="Son 1" visible="true"/>
<reportingTab tabName="Son 2" visible="true"/>
</reportingTab>
<reportingTab tabName="Parent Tab 2" visible="false">
<reportingTab tabName="Child 1" visible="true"/>
<reportingTab tabName="Child 2" visible="true"/>
</reportingTab>
</reportingTabCollection>
</reportingTabCollectionSection>
Or like a structure of this class
Public Class ReportTab
Public Property TabName As String
Public Property Visible As Boolean
Public Property SubTab As IList(Of ReportTab)
End Class

Related

Is there a way to insert Checkbox and Combobox in Sidebar in SAPUI5?

I have created a tnt Sidebar and want to insert Checkboxes and Combobox in it.
This should be the result:
Currently it looks like this:
So the NavigationItems should be replaced by Checkboxes. f.E. sap.m.CheckBox
<content>
<tnt:ToolPage>
<tnt:sideContent>
<tnt:SideNavigation id="sideNavigation" selectedKey="subItem3">
<tnt:NavigationList>
<tnt:NavigationListItem text="Item 1" icon="sap-icon://employee">
<tnt:NavigationListItem text="Sub Item 1" >
</tnt:NavigationListItem>
<tnt:NavigationListItem text="Sub Item 2" />
<tnt:NavigationListItem text="Sub Item 3" id="subItem3" key="subItem3" />
<tnt:NavigationListItem text="Sub Item 4" />
</tnt:NavigationListItem>
<tnt:NavigationListItem text="Item 2" icon="sap-icon://building">
<tnt:NavigationListItem text="Sub Item 1" />
<tnt:NavigationListItem text="Sub Item 2" />
<tnt:NavigationListItem text="Sub Item 3" />
<tnt:NavigationListItem text="Sub Item 4" />
</tnt:NavigationListItem>
</tnt:NavigationList>
I tried to insert a sap.m.CheckBox instead of a normal NavigationListItem but then I get an error, that the "CheckBox" class is under the "items" aggregation and must match the "NavigationListItem" type.
I know Fiori/UI5 is limited somehow and you shouldn't mix up too much different namespaces, but is there some workaround?
Kind regards
Sebastian
I'm not sure what you are trying to do, but maybe creating a List or TreeList with a CustomListItem would help you more.
You can put it into a SplitApp and have a "Navigation like" Panel too, but fully customizable.

.Net MAUI data binding not carrying through to custom component

I am having trouble getting data binding to work with custom components.
I have created an IncrementValue property that gets incremented with every button click.
The changes are reflected when binded to a Label.
However they do not work when I bind it to a Bindable property in a custom component.
In the example, I have built a custom component called Card which has two bindable properties CardTitle and CardIncrement
Is there something I'm missing as I'm new to MAUI and even Xamarin.
Github link of code snippets below: https://github.com/814k31/DataBindingExample
Card.xaml.cs
namespace DataBindingExample;
public partial class Card : VerticalStackLayout
{
public static readonly BindableProperty CardTitleProperty = BindableProperty.Create(nameof(CardTitle), typeof(string), typeof(Card), string.Empty);
public static readonly BindableProperty CardIncrementProperty = BindableProperty.Create(nameof(CardIncrement), typeof(int), typeof(Card), 0);
public string CardTitle
{
get => (string)GetValue(CardTitleProperty);
set => SetValue(CardTitleProperty, value);
}
public int CardIncrement
{
get => (int)GetValue(CardIncrementProperty);
set => SetValue(CardIncrementProperty, value);
}
public Card()
{
InitializeComponent();
BindingContext = this;
}
}
Card.xaml
<?xml version="1.0" encoding="utf-8" ?>
<VerticalStackLayout
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:databindingexample="clr-namespace:DataBindingExample"
x:DataType="databindingexample:Card"
x:Class="DataBindingExample.Card"
Spacing="25"
Padding="30,0"
VerticalOptions="Center"
BackgroundColor="red"
>
<Label
Text="{Binding CardTitle}"
SemanticProperties.HeadingLevel="Level1"
FontSize="32"
HorizontalOptions="Center"
/>
<Label
Text="{Binding CardIncrement}"
SemanticProperties.HeadingLevel="Level1"
FontSize="32"
HorizontalOptions="Center"
/>
</VerticalStackLayout>
MainPage.xml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="DataBindingExample.MainPage"
xmlns:DataBindingExample="clr-namespace:DataBindingExample"
xmlns:ViewModels="clr-namespace:DataBindingExample.ViewModels"
x:DataType="ViewModels:MainPageViewModel"
>
<ScrollView>
<VerticalStackLayout
Spacing="25"
Padding="30,0"
VerticalOptions="Center"
>
<Label
Text="{Binding IncrementedValue}"
SemanticProperties.HeadingLevel="Level2"
FontSize="18"
HorizontalOptions="Center"
/>
<!-- Why doesnt this work? -->
<DataBindingExample:Card CardIncrement="{Binding IncrementedValue}" />
<Button
x:Name="CounterBtn"
Text="Click Me"
SemanticProperties.Hint="Counts the number of times you click"
Command="{Binding IncrementValueCommand}"
HorizontalOptions="Center"
/>
</VerticalStackLayout>
</ScrollView>
</ContentPage>
When making a custom component (that includes XAML), DO NOT set BindingContext = this;.
REASON: You want the component to use the SAME BindingContext as the page it is placed in. This happens automatically, if you do NOT set a BindingContext in the custom component.
HOWEVER, removing this line breaks all your component's xaml Bindings; you'll need to add something to the xaml, to fix this.
Or to put it another way: How refer to the card's Properties from its XAML? See the next section.
ACCESS COMPONENT PROPERTIES VIA x:Name
Solution: Give the card an x:Name, and make that the "Source" of those bindings:
<VerticalStackLayout
...
x:Name="me" <-- IMPORTANT! Change name as desired.
x:Class="DataBindingExample.Card"
>
...
<Label Text={Binding CardIncrement, Source={x:Reference me}}"
...
Notice the two parts to this solution:
In component's xaml header, define x:Name="mynamehere".
In each Binding, say that the component is the source:
, Source={x:Reference mynamehere}.
OPTIONAL: If custom component has a "ViewModel":
To have a custom component be "data-driven", pass in a parameter that controls its behavior.
This parameter could be considered a "ViewModel", but above I have specified:
DO NOT set a BindingContext (so that component has easy access to the page's BindingContext).
So unlike other uses of ViewModel, in this technique, we don't set the ViewModel as the BindingContext.
How access this ViewModel?
By saving it as a property of the component; e.g.:
public partial class MyComponent : ContentView
{
private MyViewModel VM;
public void MyComponent(MyViewModel vm)
{
InitializeComponent();
VM = vm;
}
public class MyViewModel : ObservableObject
{
[ObservableProperty]
SomeType someProperty; // This is field. Property "SomeProperty" is generated.
}
Then in xaml, we access properties of VM, using . notation:
<Label Text={Binding VM.SomeProperty, Source={x:Reference me}}"

How to add content from C# to XAML

I have used a litle XamarinForms before and then i did a
naming to be able to point the c# code to it.
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MauiTest.MainPage"
BackgroundColor="{DynamicResource SecondaryColor}">
<StackLayout x:name="_stacklayoutname">
<Label Text="" x:Name="_Lable"/>
</StackLayout>
</ContentPage>
And then i did like this in the MainPage.xaml.cs
public MainPage()
{
InitializeComponent();
_stacklayoutname.Children.Add(new Label { Text = "TEST" });
_Lable.Text = "TEST";
}
now it get this, but i can change the _Lable to "Text".
how can i point to a stacklayout.
Severity Code Description Project File Line Suppression State
Error CS0103 The name '_stacklayoutname' does not exist in the current context MauiTest (net6.0-android), MauiTest (net6.0-ios), MauiTest (net6.0-maccatalyst), MauiTest (net6.0-windows10.0.19041) *** 11 Active
this is wrong
<StackLayout x:name="_stacklayoutname">
it should be
<StackLayout x:Name="_stacklayoutname">

Strange Checkbox behaviour using MVVM in ZK Framework

I've found strange behaviour of zk checkbox in MVVM. I made a MVVM form that shows list of items and detailed view of selected item. I placed checkbox on detailed view and bind it to boolean property of my POJO. And when I select an item with true value of this property checkbox is displayed checked, but next when I select an item with false value of property and then select an item with true value again checkbox is displayed unchecked.
I can illustrate this issue using ZK's MVVM tutorial http://books.zkoss.org/wiki/ZK_Getting_Started/Get_ZK_Up_and_Running_with_MVVM (source code http://sourceforge.net/projects/zkbook/files/GettingStarted/getzkup-20131127.zip/download )
Add to Car class boolean property:
private Boolean cool = false;
public Car(Integer id, String model, String make, String description, String preview, Integer price, boolean cool){
this.id = id;
this.model = model;
this.make = make;
this.preview = preview;
this.description = description;
this.price = price;
this.cool = cool;
}
public Boolean getCool() {
return cool;
}
public void setCool(Boolean cool) {
this.cool = cool;
}
Change CarServiceImpl.java to initialize boolean property for our demo:
carList.add(
new Car(id++,
"Camry",
"Toyota",
"The Toyota Camry is a midsize car ... ",
"/img/car3.png",
24170, true));
carList.add(
new Car(id++,
"Century",
"Toyota",
"The Toyota Century is ... " ,
"/img/car4.png",
28730, true));
Change searchMvvm.zul (add lines labeled as INSERTED):
<window title="Search" width="600px" border="normal" apply="org.zkoss.bind.BindComposer"
viewModel="#id('vm') #init('tutorial.SearchViewModel')">
<hbox align="center">
Keyword:
<textbox value="#bind(vm.keyword)" />
<button label="Search" image="/img/search.png" onClick="#command('search')" />
</hbox>
<listbox height="160px" model="#bind(vm.carList)" emptyMessage="No car found in the result"
selectedItem="#bind(vm.selectedCar)">
<listhead>
<listheader label="Model" />
<listheader label="Make" />
<listheader label="Price" width="20%"/>
<listheader label="Cool" /> <!-- INSERTED -->
</listhead>
<template name="model">
<listitem>
<listcell label="#bind(each.model)"></listcell>
<listcell label="#bind(each.make)"></listcell>
<listcell>$<label value="#bind(each.price)" /></listcell>
<listcell><checkbox checked="#bind(each.cool)" /></listcell> <!-- INSERTED -->
</listitem>
</template>
</listbox>
<hbox style="margin-top:20px">
<image width="250px" src="#bind(vm.selectedCar.preview)" />
<vbox>
<label value="#bind(vm.selectedCar.model)" />
<label value="#bind(vm.selectedCar.make)" />
<label value="#bind(vm.selectedCar.price)" />
<label value="#bind(vm.selectedCar.description)" />
<checkbox checked="#bind(vm.selectedCar.cool)" label="Cool" /> <!-- INSERTED -->
</vbox>
</hbox>
After that start Tomcat and enter localhost:8080/tutorial/searchMvvm.zul in your browser. When you click on Toyota Camry item everything is ok, but when you click on Nissan Cifiro and then on Toyota Camry again checkbox in detaled view will be displayed unchecked. But checkbox in listbox works fine.
Do you know any workaround to solve this problem?
I have the same problem, but it was fixed when I change getCool() with isCool() (on ZK V7)
I'm using ZK7 and I had the same problem.
I got a :
Property 'standard' not readable on type
on the Boolean standard, which has getter isStandard and setter setStandard
The solution is:
When using Boolean (the object) then you have to use get-Prefix
When using boolean (the primitive) then you can use is-Prefix
That's it !
You should use
checkbox.setCheck(Boolean.valueOf(true));

SilverLight 4.0 C# - DomainDataSource DataGrid with CheckBox Column (UI only - not a data field) to allow user to select multiple records/rows

New to SilverLight and to posting here. Please have mercy and be specific :)
Using RIA services with DomainDataSource and DataGrid control to display data rows from SQL server query
Goal: Have checkbox column (UI only - not a data field) to allow user to select multiple records/rows
BackGround:
1) Created new SilverLight 4, C# solution with RIA services
2) in ProjectName.Web
Created Entity Framework (EF) model referencing SQL server table/view (built solution).
Created Domain Sevice using EF model (built solution).
3) in SilverLightProjectName
From Data Sources window, dragged table onto a design surface to create DomainDataSource and DataGrid (this works great to bind DataGrid to data source)
4) in MainPage.XAML added checkbox column
What's Happening: checkboxes are selected/checked by user, scroll down, scroll back up, all checkboxes reset and ONLY Datagrid.SelectedItem is still checked. I have read this behavior is 'by design' due to paging.
<sdk:DataGrid RowStyle="{StaticResource newDataGridStyle}" AutoGenerateColumns="False" ItemsSource="{Binding ElementName=ddsPagerApp, Path=Data}" Name="vwPagerAppDataGrid" RowDetailsVisibilityMode="VisibleWhenSelected" MouseLeftButtonDown="vwPagerAppDataGrid_MouseLeftButtonDown" VerticalGridLinesBrush="#FFB9B9B9" FontSize="10" Grid.Row="3" SelectionChanged="vwPagerAppDataGrid_SelectionChanged" KeyDown="vwPagerAppDataGrid_KeyDown" MouseLeftButtonUp="vwPagerAppDataGrid_MouseLeftButtonUp" MouseRightButtonUp="vwPagerAppDataGrid_MouseRightButtonUp" DataContext="{Binding}" SelectionMode="Single" IsEnabled="True" IsReadOnly="False" TabIndex="2" Grid.Column="1" Margin="0,10,9,9">
<sdk:DataGrid.Columns>
<sdk:DataGridTemplateColumn IsReadOnly="False">
<sdk:DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<CheckBox Name="ChkSelected" IsThreeState="False" IsChecked="{Binding Path=IsChecked, Mode=TwoWay}" HorizontalAlignment="Center" VerticalAlignment="Center" Unchecked="IndividualCheckBox_Unchecked" Checked="IndividualCheckBox_Checked" Width="Auto" Height="Auto" />
</DataTemplate>
</sdk:DataGridTemplateColumn.CellEditingTemplate>
</sdk:DataGridTemplateColumn>
<sdk:DataGridTextColumn x:Name="fullNameColumn" Binding="{Binding Path=FullName}" Header="Full Name" IsReadOnly="True" />
<sdk:DataGridTextColumn x:Name="departmentColumn" Binding="{Binding Path=department}" Header="Department" IsReadOnly="True" />
<sdk:DataGridTextColumn x:Name="pager_number_displayColumn" Binding="{Binding Path=pager_number_display}" Header="Pager Number" IsReadOnly="True" />
<sdk:DataGridTextColumn x:Name="PageTo" Binding="{Binding Path=PageTo}" Header="Page To" IsReadOnly="True" />
</sdk:DataGrid.Columns>
</sdk:DataGrid>
<riaControls:DomainDataSource AutoLoad="True" d:DesignData="{d:DesignInstance my:vwPagerApp, CreateList=true}" Height="0" LoadedData="ddsPagerApp_LoadedData" Name="ddsPagerApp" QueryName="GetVwPagerAppsQuery" Width="0" Margin="10,0,25,45" Background="#FF7D0000" Foreground="#FF7D0000" Visibility="Visible">
<riaControls:DomainDataSource.DomainContext>
<my:NotifyDomainContext />
</riaControls:DomainDataSource.DomainContext>
</riaControls:DomainDataSource>
Attempt 1:
in EFModel.edmx, added Boolean Scalar Property 'IsChecked'
in DomainService.metadata.cs, added public bool IsChecked { get; set; }
in MainPage.XAML. added (above) IsChecked="{Binding Path=IsChecked, Mode=TwoWay}"
Getting error: Error 11009: Property ' ' is not mapped
UPDATE: Reversed Attempt 1:
Attempt 2:
Researching possibility of defining a partial class for the entity, wiring to DataGrid, and using that to track CheckBox values. Any advice on if this will work/how to?
Trying my best to absorb this. Please enlighten me...and thank you in advance :)
This is what I implemented and it worked beautifully. I hope it helps someone else in the future :)
1) SilverLight Project C#: Extend entity class using partial class (in separate file, but within same namespace – compiles into 1 class but keeps generated code separate)
namespace Pager.Web
{
public partial class pager_grp
{
bool _IsChecked = false;
public bool IsChecked
{
get
{return this._IsChecked;}
set
{this._IsChecked = !IsChecked;}
}
}
}
2) SilverLight Project GUI: Create Column in DataGrid of type DataGridTemplateColumn named chkSelected
3) SilverLight Project XAML: use template and bind to new property declared in partial class
<sdk:DataGridTemplateColumn IsReadOnly="False">
<sdk:DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<CheckBox Name="ChkSelected" IsThreeState="False" IsChecked="{Binding Path=IsChecked, Mode=TwoWay}" HorizontalAlignment="Center" VerticalAlignment="Center" Unchecked="IndividualCheckBox_Unchecked" Checked="IndividualCheckBox_Checked" Width="Auto" Height="Auto" />
</DataTemplate>
</sdk:DataGridTemplateColumn.CellEditingTemplate>
</sdk:DataGridTemplateColumn>