How to use ToggleButton in Xaml - xaml

I want to use the ToggleButton in my Xaml Grid Layout with
<ToggleButton Grid.Row="0" Grid.Column="0"/>
but get an Error
The Type 'ToggleButton' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been build.
What am I doing wrong?

Related

UWP Xaml Binding properties to an other page in a splitview

i need a little hand on this please,
Context : Windows 10 UWP Development, C#, Visual Studio 2017
I don't understand why I can pass INotify properties in my code, but i can not in the GEDContenuPage page view, that I want to add in the left pane of my SplitView.
<SplitView Grid.Row="1"
IsPaneOpen="{Binding IsGEDOpen}"
DisplayMode="Inline"
OpenPaneLength="{Binding GEDPaneWidth}">
<SplitView.Pane>
<Grid>
<v:GEDContenuPage Visibility="{Binding IsGEDOpen, Converter={StaticResource BoolToVisibilityConverter}}" />
</Grid>
</SplitView.Pane>
<ScrollViewer >
<Grid x:Name="mainGridData" />
</ScrollViewer>
</SplitView>
IsPaneOpen="{Binding IsGEDOpen}" will works and do its job (open or close left pane)
BoolToVisibilityConverter is in app.xaml and works well (tested somewhere else)
I have also created a DependencyPropertyin my page control :
<v:GEDContenuPage
Visibility="{Binding IsGEDOpen, Converter={StaticResource BoolToVisibilityConverter}}"
ext:GEDContenuPageExtension.ContenuId="2446"
/>
Same thing here, 2446 will works well, This will open my left pane with the right content.
But I i try to replace it with a Binding :
ext:GEDContenuPageExtension.ContenuId="{Binding GedContenuId}
It won't work.
I guess this is end of the week, and the only thing I need is a fresh beer to put things right in my mind...
For your information, the left pane will receive other page than GEDContenuPage. This is why I need a visibility property for each page.
Thanks for help,
OK this was a datacontext issue, this done the trick
<Grid Name="parentGrid">
<v:GEDContenuPage Visibility="{Binding DataContext.IsGEDOpen, Converter={StaticResource BoolToVisibilityConverter}, ElementName=parentGrid}" />

Reference string resource in Windows Phone 8.1 XAML

I am unclear how do I reference a control text property using string resources in Windows Phone 8.1?
For instance I have:
<HubSection x:Name="MySection" HeaderTemplate="{StaticResource MyHeaderTemplate}" Header="{StaticResource MyText}">
and
<AppBarButton Name="MyAppBar" Label="{StaticResource MyText}" ...>
and
They both reference MyText which I want to load from resource .resx file.
To Refer Any control Property from resources in the XAML, create a x:Uid for that control say for a TextBlock, I made a control like :
<TextBlock x:Uid="Header" Text="from Resx" Style="{ThemeResource TitleTextBlockStyle}"/>
And in the Resources.resx define a new Resource with name Header.Text and Value as desired say, My Header Text. See the screenshot below :

x:name of controls in ApplicationViewStates

I am working in windows store apps and I need help..
I am trying to adapt my app for the differents visual state (FullScreenLandscape, FullScreenPortrait, Snapped, etc) and I need to reuse the controls for each visual state..
I create a grid for each visual state for example
<Grid x:Name="PortraitView" Visibility="Collapsed">
</Grid>
<Grid x:Name="FillView" Visibility="Visible">
</Grid>
<Grid x:Name="SnapView" Visibility="Collapsed">
</Grid>
but my problem is that I can not repeat the x:name of the controls that I set in the Grid= PortraitView..
how can I resolve it?
thanks
From MSDN
The most common usage of this property is to specify a XAML element
name as an attribute in markup. This property essentially provides a
WPF framework-level convenience property to set the XAML x:Name
Directive.
Names must be unique within a namescope.
For more information, see XAML Namescopes.

How to use x:Uid in windows phone 8?

We can use x:Uid in windows-8 as
Where in .resw I have define
mainTitle.Text = "Your Name"
In this way TextBlock's text becomes Your Name.
How can I achieve the same in windows phone 8?
When I put mainTitle.Text in .resx it gives error.
You have to use binding in Windows Phone 8.
The most simple way to see this in action is to create a new project and take a look at MainPage.xaml. The binding is demonstrated in the following comment
For example:
Text="{Binding Path=LocalizedResources.ApplicationTitle, Source={StaticResource LocalizedStrings}}"
To localize some text, you bind the LocalizedStrings class (created with the project) which wraps your static Resource file.
<TextBlock Text="{Binding Path=LocalizedResources.ApplicationTitle, Source={StaticResource LocalizedStrings}}" />
The LocalizedStrings resource is already there in your App.xaml
<local:LocalizedStrings x:Key="LocalizedStrings"/>
You can use binding here
<TextBlock Text="{Binding Path=LocalizedResources.ApplicationTitle, Source={StaticResource LocalizedStrings}}"/>
For more about localization read How to build a localized app for Windows Phone
And to know about x:Uid read x:Uid Directive
Binding is one solution but simply you can do the following.
If you have the following AppBarButton
<AppBarButton
Name="AppBarButtonMore"
x:Uid="appbar_more_title"
Click="AppBarButtonMore_Click"/>
add the string file with the key appbar_more_title.Label to your resources and your button will take that string as label property.This is also valid for any UI controls.

How to reuse XAML code blocks without binding?

I have this XAML code block:
<StackPanel Orientation="Horizontal">
<TextBlock Text="Hello " />
<TextBlock Text="World" />
</StackPanel>
I would like to define this block (for example in /Common/CustomStyles.xaml) to include it on different XAML pages. How does it work?
I do not need a DataTemplate or something similar because the text is static.
You could put it in a user control and re-use it that way. If it's just the text you are interested in then you could use a resource file - this would update the textbox on any screen as long as it had the right uid.