[c++]How to bind FontSize and specify font size as "pt", "in" and "cm"
Hi,
I try to bind FontSize and specify "pt".
How to convert from NsString to float?
In WPF, it can convert from string to double by FontSizeConverter().
XAML
cpp
I try to bind FontSize and specify "pt".
How to convert from NsString to float?
In WPF, it can convert from string to double by FontSizeConverter().
XAML
Code: Select all
<TextBlock FontSize="{Binding FontSize}"... />
Code: Select all
float GetFontSize() const{
NsString fontSizeString = "20pt";
float fontSize;
//Convert from NsString to float
return fontSize;
}
-
-
sfernandez
Site Admin
- Posts: 2062
- Joined:
Re: [c++]How to bind FontSize and specify font size as "pt", "in" and "cm"
This is a bug, our FontSize property doesn't have a FontSizeConverter assigned, it only accepts float values, could you please report it?
In the meantime you can create a LengthConverter and use it to obtain the font size from the string value:
In the meantime you can create a LengthConverter and use it to obtain the font size from the string value:
Code: Select all
class ViewModel: public BaseComponent
{
public:
ViewModel()
{
mFontSizeConverter = NsCreateComponent<TypeConverter>(NsSymbol("Converter<Length>"));
}
void UpdateFontSize(const char* size)
{
Ptr<BaseComponent> result;
if (mFontSizeConverter->TryConvertFromString(size, result))
{
mFontSize = Boxing::Unbox<float>(result);
}
}
...
private:
Ptr<TypeConverter> mFontSizeConverter;
float mFontSize;
};
-
-
sfernandez
Site Admin
- Posts: 2062
- Joined:
Re: [c++]How to bind FontSize and specify font size as "pt", "in" and "cm"
Thanks for the report.
Who is online
Users browsing this forum: No registered users and 2 guests